This repository contains a simple voting smart contract that can be deployed on the Base Network using Remix IDE. Users can vote for candidates, and each wallet is allowed to vote once.
- Go to https://remix.ethereum.org
- Connect your wallet (e.g., MetaMask) to the Base network (Testnet or Mainnet).
- In Remix, create a new file:
contracts/Voting.sol - Paste the smart contract code from
Voting.solinto the file.
- Select Solidity compiler version: 0.8.20
- Enable optimization (optional)
- Click Compile Voting.sol
Ensure there are no compilation errors.
- Environment: Injected Web3
- Network: Base Testnet/Mainnet
- Constructor parameter: Array of candidate names, e.g.:
["Alice", "Bob", "Charlie"]
- Click Deploy and confirm the transaction in your wallet.
- Open the Deployed Contracts section in Remix:
vote(candidateId)→ Cast your vote for a candidate.candidateIdstarts from 0.- Example:
0for Alice,1for Bob, etc.
getCandidate(candidateId)→ Check the candidate's name and vote count.
- Each wallet can vote only once.
- This is a simple educational example for testing and learning.
- For production usage, consider:
- Adding voting periods
- Token-weighted voting
- Security audits