Giter Club home page Giter Club logo

e-voting-ethereum's Introduction

E-Voting-Ethereum

A Blockchain based code for E Voting System which prevents miscounting of votes and stores the votes in different locations so that they cannot be tampered with.

Smart Contract

The election.sol placed in /ethereum/contracts is written in solidity v0.4.17 which contains the smart contract written for returning a list of voters, add a candidate, add a voter, cast a vote, return a candidate, return list of candidates, and much more. The manager can also add candidates or voters to the contract. The manager will be the one who deploys the smart contract. Only the manager can find the complete results of the eletion. We have calculated the number of voted for a particular candidate by iterating a chain. This number is then typecasted to uint. We also add a require statement in calculateVotes() which checks if the function is called by the manager or not. If not, then this function will not return anything. You can read more about smart contracts here. You can read more about the solidity language here.

Compiling the Smart Contract

To compile the smart contract we will be using solc compiler which is used to compile solidity codes. The compile code is placed in compile.js. The code is written in JavaScript.

Testing our Smart Contract

The election.test.js file, written in JavaScript tests our smart contracts by using multiple testcases written in it. We will be using mocha as the testing framework. Read more about mocha here.

Deploying our Smart Contract

The deploy.js file will deploy our smart contract to the Rinkeby Test Network. This network is similar to the main Ethereum Network but the only difference is that we don't need to pay for deploying our smart contracts. It works completely on the concept of virtual money.

Steps to configure the project and to run our Smart Contract and deploy it on Rinkeby TestNet.

  1. Clone this source repository on your desired local path on machine.
  2. Install NodeJS in your computer from here. Use the recommended version.
  3. Install Git in your computer from here.
  4. Open up your cmd. Navigate to the folder Lottery in your cmd.
  5. Run the command- 'npm init' in our Lottery folder. This will create a package.json file in your directory.
  6. Install packages Truffle, Mocha, Ganache-CLI and Web3 by running the command 'npm install --save [email protected] mocha ganache-cli web3'. Truffle is a development environment, testing framework and asset pipeline for Ethereum. Mocha is a testing framework which will be required by our lottery.test.js file. Ganache provides a environment for truffle. Web3 is a collection of libraries which allows you to interact with a local or remote ethereum node.
  7. To compile our smart contract, run command 'node compile.js'.
  8. To test our smart contract, run 'npm run test'.
  9. Install MetaMask which is an extension for browsers like Chrome to easily track your transactions and accounts.
  10. Finally, deploy our contract on the Rinkeby network by running command 'node deploy.js'

e-voting-ethereum's People

Contributors

thedecepticon30 avatar

Stargazers

Mohammed Ajnas k avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.