Artemis is a decentralized application (DApp) that leverages Ethereum blockchain technology to provide a secure and transparent voting system. Built with Solidity, Hardhat, and a React frontend, Artemis allows users to vote for candidates in a decentralized manner using their MetaMask wallets.
- Introduction
- Technologies Used
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- Application Overview
- Commands Summary
- Future Enhancements
Artemis provides a secure, transparent voting platform where each vote is recorded on the blockchain, ensuring integrity and immutability. The application is built to simulate real-world voting systems in a Web3 environment, using Solidity for the backend logic and a React frontend for an engaging user experience.
- Solidity: For implementing the voting logic as a smart contract on Ethereum.
- Hardhat: Ethereum development environment to compile, test, and deploy the contract.
- Ganache: Local blockchain for testing and development.
- React: Frontend framework for building the Web3 interface.
- Ethers.js: Ethereum JavaScript library for interacting with the blockchain.
- Tailwind CSS: Styling library for a responsive, modern UI.
- Blockchain-Backed Voting: Ensures secure and immutable records of votes.
- MetaMask Wallet Authentication: Users connect their MetaMask wallet to verify identity and cast votes.
- Real-Time Voting Status: Displays active voting session status and remaining time.
- Vote Once Mechanism: Each voter can cast only one vote per session, enforcing fairness.
- Node.js (v14 or later)
- Hardhat for contract development
- Ganache for local blockchain testing
- MetaMask for connecting to the Ethereum network via browser
Clone the repository and install dependencies:
git clone https://github.com/TheODDYSEY/Voting-DApp-Solidity
cd Voting-DApp-Solidity
npm install
-
Environment Variables: Create a
.env
file in the project root directory with the following:API_URL=http://127.0.0.1:7545 PRIVATE_KEY=your_ganache_private_key
-
Ganache Setup: Start Ganache on
http://127.0.0.1:7545
and use one of its account private keys in the.env
file.
Generate the necessary ABI and bytecode by compiling the contracts:
npx hardhat compile
Deploy the Voting
contract to the local Ganache blockchain:
npx hardhat run scripts/deploy.js --network ganache
To validate the functionality and accuracy of the smart contract:
npx hardhat test --network ganache
Start the React frontend to interact with the deployed contract:
npm start
The Solidity-based voting contract defines core functionalities, including:
- Candidate Management: Initializes candidates and allows voting on them.
- Vote Tracking: Keeps track of individual votes and prevents multiple voting attempts per session.
- Session Timing: Limits voting to a specified duration, after which voting is closed and results can be viewed.
The React frontend facilitates user interactions and displays voting details. Key components include:
- Login Component: Enables users to connect their MetaMask wallet to access the application.
- Connected Component: Displays the main voting interface with candidate options, remaining time, and vote submission.
- Finished Component: Displays a message indicating the end of the voting session, thanking users for their participation.
Each component is styled with Tailwind CSS, providing a clean, responsive interface. The app uses Reactβs state and props to update in real-time as users connect their wallets, cast votes, and monitor session status.
-
Login Screen
Allows users to connect their MetaMask wallet to access the DApp.
-
Voting Interface (Connected)
Shows the candidate list, remaining time, and vote submission options.
-
Voting Finished Screen
Displays a thank-you message when the voting session concludes.
Command | Description |
---|---|
npm install |
Install project dependencies |
npx hardhat compile |
Compile the smart contracts |
npx hardhat run scripts/deploy.js --network ganache |
Deploy contracts on Ganache |
npx hardhat test --network ganache |
Run contract tests on Ganache |
npm start |
Start the React frontend |
- Analytics and Visualization: Add visual components for displaying vote counts and participation statistics.
- Blockchain Explorer Integration: Link votes and results to a blockchain explorer for greater transparency.
- Enhanced Session Management: Implement automated session management to close or restart voting sessions based on smart contract logic.