r/solanadev • u/fernandopereira08 • 1h ago
New lesson "On-chain Polls". Looking for feedback!
I built on-chain polls on Solana in Rust where each wallet can vote only once, and there's no list of voters anywhere.
The rule doesn't come from an if statement. It comes from the address of an account.
The lesson covers:
→ Every vote creates a small receipt account at a PDA derived from compound seeds (vote, poll, voter), so a second vote from the same wallet fails because that account already exists
→ Poll state modeled with a fixed-size Vec of options and a PollStatus enum (Open or Closed)
→ Custom Anchor constraints with their own errors, reading the instruction's arguments, so a bad vote fails before the handler runs
→ A real bug caught by the tests: with only the voter in the seeds, the same wallet couldn't vote on a second poll. One extra seed fixed it
→ Tests with LiteSVM for the happy path and every failure case, a devnet deploy, and a small React front end with a Codama-generated client and Phantom
I'd really appreciate feedback, especially from people interested in learning Solana development:
- Was the explanation clear and easy to follow?
- Was the pace appropriate for someone learning Anchor?
- Did I explain the underlying concepts well enough, or were there parts that needed more detail?
- What topics would you like to see covered in future lessons?
I'm continuously working on improving the way I teach complex blockchain concepts, so honest feedback is very welcome.
Thanks for watching!