We Now Have a Comment System
This Blog Now Has Comments
I never had a comment system on this blog, but now you can leave comments. I could have gone with a simple database-backed approach, but instead I stored them on the blockchain. So your comments will drift through the internet semi-permanently. You’ve been warned. Currently you can post using an Ethereum wallet or Google login. I might add more options later. Gas fees are on me, so don’t worry about that. If you have an ENS name, it’ll show up too.
How It Works
Source code here Blog implementation example here
Comments are stored using a smart contract — a program that runs on the blockchain. The implementation is in Solidity. You pass a wallet address, comment, username, etc. to the contract, and it gets written to the blockchain. Simple as that. So wallet users can call the contract directly to post comments, though you’d have to pay the gas fees yourself in that case1.
The actual comment submission is handled by a relayer — a server program (the relayer directory in the golos repo).
It’s built with TypeScript + Hono and deployed on Cloudflare Workers.
The signing happens on the frontend, and the relayer takes care of submitting the transaction on the user’s behalf.
By going through the relayer, users without a wallet can post comments by logging in with Google.
Thoughts
I built this to learn about smart contracts, and I feel like I’ve gained a much better understanding. Blockchain is a great fit for use cases that demand transparency. Censorship and tampering resistance might be overkill for blog comments. But the fact that you can get these properties just by paying a small fee, without setting up a database, is a pretty nice experience. Give it a try — smart contracts!
Footnotes
-
It’s possible to implement it so that gas fees are covered on our end for direct calls too, but there’s no real need, so I didn’t bother. ↩