Skip to content

anj20/VoteChain

Repository files navigation


BlockVoteChain

BlockVoteChain is a decentralized voting application built on blockchain technology. This repository contains all the necessary code and resources to run the BlockVoteChain application.

Features

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

Prerequisites

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)

Installation

  1. Clone this repository to your local machine:

    git clone https://github.com/anj20/BlockVoteChain.git
  2. Install the project dependencies:

    cd BlockVoteChain
    npm install
  3. 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.

Hardhat Deployment Steps

To deploy the smart contracts on a blockchain network using Hardhat, follow these steps:

1. Install Hardhat

If you haven't already installed Hardhat, you can do so by running:

npm install --save-dev hardhat

2. Initialize 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.

3. Configure Hardhat

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.

4. Write Deployment Script

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.

5. Deploy Contracts

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.

Usage

  1. Start Ganache to create a local blockchain for testing and development:

    npx ganache-cli
  2. Compile and deploy the smart contracts to the local blockchain:

    npx hardhat run scripts/deploy.js --network development
  3. Start the development server:

    npm start
  4. Open your browser and go to http://localhost:3000 to access the BlockVoteChain application.

  5. Use MetaMask to interact with the application and cast your vote.

License

BlockVoteChain is licensed under the MIT License. Feel free to use, modify, and distribute this code for both commercial and non-commercial purposes.

Acknowledgements

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.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published