Skip to content

fafaonchain/Create-Voting-DApps

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Base Voting dApp

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.


1. Open Remix IDE


2. Create Contract File

  • In Remix, create a new file:
    contracts/Voting.sol
  • Paste the smart contract code from Voting.sol into the file.

3. Compile Contract

  • Select Solidity compiler version: 0.8.20
  • Enable optimization (optional)
  • Click Compile Voting.sol

Ensure there are no compilation errors.


4. Deploy Contract

  • 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.

5. Interact with Contract

  • Open the Deployed Contracts section in Remix:

Voting

  • vote(candidateId) → Cast your vote for a candidate.
    • candidateId starts from 0.
    • Example: 0 for Alice, 1 for Bob, etc.

View Results

  • getCandidate(candidateId) → Check the candidate's name and vote count.

Notes

  • 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

About

Create Voting DApps Using Remix IDE (BASE CHAIN)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors