BlockVoteChain is a decentralized voting application built on blockchain technology. This repository contains all the necessary code and resources to run the BlockVoteChain application.
- Decentralized Voting: BlockVoteChain enables decentralized voting, allowing participants to cast their votes directly without the need for intermediaries.
- Transparent and Immutable: All voting data is stored on the blockchain, ensuring transparency and immutability of the voting process.
- Security: BlockVoteChain utilizes cryptographic techniques to ensure the security and integrity of the voting system.
- Easy to Use: The application provides a user-friendly interface for voters to participate in the voting process.
To run the BlockVoteChain application, you need to have the following prerequisites:
- Node.js (version 12 or higher)
- Hardhat (development environment for Ethereum)
- Ganache (for local blockchain development)
- MetaMask (browser extension for interacting with the Ethereum network)
-
Clone this repository to your local machine:
git clone https://github.com/anj20/BlockVoteChain.git
-
Install the project dependencies:
cd BlockVoteChain npm install
-
Configure MetaMask:
- Install the MetaMask extension in your browser.
- Create a new Ethereum network and connect to it.
- Import an account with test Ether provided by Ganache.
To deploy the smart contracts on a blockchain network using Hardhat, follow these steps:
If you haven't already installed Hardhat, you can do so by running:
npm install --save-dev hardhat
If you haven't initialized Hardhat in your project, do so by running:
npx hardhat
Follow the prompts to create a basic Hardhat project.
Ensure your hardhat.config.js
is configured correctly for the network you want to deploy to. For local development, it might look something like this:
require('@nomiclabs/hardhat-ethers');
module.exports = {
solidity: "0.8.0",
networks: {
development: {
url: "http://127.0.0.1:8545",
accounts: [`0x${YOUR_PRIVATE_KEY}`]
}
}
};
Replace YOUR_PRIVATE_KEY
with the private key of an account you want to use for deployment.
Create a deployment script in the scripts
folder. For example, deploy.js
:
async function main() {
const [deployer] = await ethers.getSigners();
console.log("Deploying contracts with the account:", deployer.address);
const Contract = await ethers.getContractFactory("YourContract");
const contract = await Contract.deploy();
console.log("Contract deployed to address:", contract.address);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Replace "YourContract"
with the name of your contract.
Run the deployment script with Hardhat:
npx hardhat run --network networkname scripts/deploy.js
This command deploys the smart contracts to the local Ganache blockchain.
-
Start Ganache to create a local blockchain for testing and development:
npx ganache-cli
-
Compile and deploy the smart contracts to the local blockchain:
npx hardhat run scripts/deploy.js --network development
-
Start the development server:
npm start
-
Open your browser and go to
http://localhost:3000
to access the BlockVoteChain application. -
Use MetaMask to interact with the application and cast your vote.
BlockVoteChain is licensed under the MIT License. Feel free to use, modify, and distribute this code for both commercial and non-commercial purposes.
BlockVoteChain was inspired by the idea of decentralized voting systems and blockchain technology. We would like to thank the open-source community for their valuable contributions and the Ethereum Foundation for providing the necessary infrastructure for building decentralized applications.