🚀 A decentralized voting application composed of three services:
- Smart Contracts (Solidity & Foundry)
- Frontend (Next.js + Wagmi + RainbowKit)
- Oracle Service (Express.js)
system-dapp-voting/
├── contract-dapp-voting # Solidity smart contracts (submodule)
│ └── ...
├── fe-dapp-voting/ # Next.js frontend application (submodule)
│ └── ...
├── oracle-dapp-voting/ # Oracle client (submodule)
│ └── ...
└── README.md # (this file)
Note: The
contract-dapp-voting/,fe-dapp-voting/, andoracle-dapp-voting/folder is a Git submodule.
git clone https://github.com/Lev1reG/system-dapp-voting.git
cd system-dapp-votingThe Oracle service is included as a submodule. After cloning, initialize and update:
git submodule init
git submodule update --init --recursiveBelow is a high-level diagram of how the three services interact:
-
Smart Contracts
- Deploy on a testnet (Sepolia).
- Emit events:
VotingSessionCreated,CandidateRegistered,Voted.
-
Oracle Service (Express.js)
- Listens to on-chain events.
- For
VotingSessionCreated: fetch HR data → determine eligible voters. - For
CandidateRegistered: save new candidate data to backend.
-
Frontend (Next.js)
- Connects Wallet (RainbowKit + Wagmi).
- Displays available sessions, candidates, vote counts.
- Calls
vote(sessionId, candidateAddr)on-chain.
-
Backend (Next.js API)
- Stores off-chain data if needed (e.g., voter eligibility).
-
Install Foundry & dependencies:
cd contract-dapp-voting forge install OpenZeppelin/openzeppelin-contracts forge build -
Deploy to a testnet:
forge script script/DeployVoting.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
-
Note the deployed contract address → set
NEXT_PUBLIC_CONTRACT_ADDRESSin frontend.
-
Move to
fe-dapp-voting/:cd ../fe-dapp-voting npm install -
Create
.env:NEXT_PUBLIC_CONTRACT_ADDRESS=0xYourContractAddress -
Start dev server:
npm run dev
-
Initialize submodule if not done:
cd ../oracle-dapp-voting git submodule init git submodule update --init --recursive -
Install dependencies:
npm install
-
Create
.env:RPC_URL=https://sepolia.infura.io/v3/[ID] PRIVATE_KEY=0xYOUR_ADMIN_PRIVATE_KEY CONTRACT_ADDRESS=0xYourContractAddress BACKEND_URL=http://localhost:3000 -
Run Oracle:
npm run dev
- Benaya Imanuela (Student ID: 22/494790/TK/54313)
- Deren Tanaphan (Student ID: 22/503261/TK/54976)

