Back to catalogue
Project
Voting DApp
Voting prototype that connects a web interface to Solidity contracts through Thirdweb.
How it’s builtHow it’s built
Voting DApp · Solidity voting contract with a React front end via Thirdweb
I wrote a Solidity voting contract where the owner registers candidates and voters, only registered voters aged 18 or over can vote, and each can vote once. I deployed it with Truffle to a local chain and built a React front end that reads and writes the contract through Thirdweb hooks.
- public contract functions
- 6
- access modifiers (onlyOwner, onlyEligibleVoter)
- 2
- Solidity compiler version
- 0.8.1
Technology and what it does here
- Solidity
- VotingSystem contract with candidate and voter mappings and vote counts
- Truffle
- Compile and migrate (2_deploy_voting.js) to a local node on 127.0.0.1:8545
- Thirdweb React SDK
- UseContract, useContractRead and useContractWrite in useVotingContract.js
- React 18 + Vite
- Dashboard for registration and voting
- SweetAlert2
- Transaction result and error dialogs
Implementation details
- onlyEligibleVoter requires age >= 18 and hasVoted == false before vote() increments the count.
- The front end targets Thirdweb's Localhost chain with the deployed contract address and ABI from src/utils/contract.json.
Technologies
- Solidity
- Thirdweb
- Web3
