learnt and deployed This repository contains a demo decentralized voting application. The application is built with a Solidity smart contract for voting and a ReactJS frontend for user interaction.
- Decentralized Voting: Voting functionality implemented in Solidity.
- ReactJS Frontend: User-friendly interface to interact with the smart contract.
- Customizable Blockchain Network: Supports various blockchain networks by configuring Hardhat.
Before getting started, ensure you have the following installed on your system:
-
Clone the repository:
git clone https://github.com/Enochthedev/decentralized-voting.git cd decentralized-voting -
Install the necessary dependencies:
npm install
Compile the Solidity contract to generate the necessary artifacts:
npx hardhat compileDeploy the contract to your blockchain network:
npx hardhat run --network volta scripts/deploy.jsNote: Replace
voltawith your desired network defined inhardhat.config.js.
-
Copy the deployed contract address from the deployment output.
-
Create a
.envfile in the root directory if it does not already exist:touch .env
-
Add the following keys to the
.envfile:REACT_APP_CONTRACT_ADDRESS=<Your_Contract_Address> PRIVATE_KEY=<Your_Private_Key> NETWORK_ENDPOINT=<Blockchain_Network_Endpoint>
Start the application locally:
npm startThe application will be available at http://localhost:3000.
To use a different blockchain network:
- Update the
networksconfiguration inhardhat.config.js. - Provide the corresponding endpoint in your
.envfile.
The Solidity contract can be extended to include additional features like weighted voting or vote delegation. Modify the contracts/ directory as needed and recompile/deploy the contract.
- Compilation Errors: Ensure the Solidity version in
hardhat.config.jsmatches your contract's pragma. - Deployment Errors: Verify your network configuration and ensure your wallet has sufficient funds for gas fees.
- React Errors: Ensure your
.envvariables are correctly configured and restart the development server.
This project is licensed under the MIT License. See the LICENSE file for more details.