Aadhaar Based voting system
Aadhaar Based voting system using blockchain technology Project implemented as part of Rajasthan Hackathron
Clone Project
git clone [email protected]:sanattaori/techdot.git && cd techdot
Install Dependencies
npm install
Running Project
node index.js
If dependency problem occurs delete package.json, Run
npm init
Again Install dependencies and run project.
Step 1 - Setting up Environment Instead of developing the app against the live Ethereum blockchain, we have used an in-memory blockchain (think of it as a blockchain simulator) called testrpc.
npm install ethereumjs-testrpc web3
Step 2 - Creating Voting Smart Contract
npm install solc
Replace your aadhaar no and phone number for running project at https://github.com/sanattaori/techdot/blob/7814403250f8b042992c6d437d9f9db8f98f3729/ui/js/app.js#L39
Step 3 - Testing in node console
Not required just for testing in node console- After writing our smart contract, we'll use Web3js to deploy our app and interact with it
$ node
> Web3 = require('web3')
> web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
Then ensure Web3js is initalized and can query all accounts on the blockchain
> web3.eth.accounts
Lastly, compile the contract by loading the code from Voting.sol in to a string variable and compiling it
> code = fs.readFileSync('Voting.sol').toString()
> solc = require('solc')
> compiledCode = solc.compile(code)
testrpc creates 10 test accounts to play with automatically. These accounts come preloaded with 100 (fake) ethers.
Deploy the contract!
dCode.contracts[‘:Voting’].bytecode: bytecode which will be deployed to the blockchain. compiledCode.contracts[‘:Voting’].interface: interface of the contract (called abi) which tells the contract user what methods are available in the contract.
> abiDefinition = JSON.parse(compiledCode.contracts[':Voting'].interface)
> VotingContract = web3.eth.contract(abiDefinition)
> byteCode = compiledCode.contracts[':Voting'].bytecode
>deployedContract = VotingContract.new(['Sanat','Aniket','Mandar','Akshay'],{data: byteCode, from: web3.eth.accounts[0], gas: 4700000})
> deployedContract.address
> contractInstance = VotingContract.at(deployedContract.address)
deployedContract.address. When you have to interact with your contract, you need this deployed address and abi definition we talked about earlier.
Step 4 - Interacting with the Contract via the Nodejs Console
> contractInstance.totalVotesFor.call('Sanat').toLocaleString()
'2'
Make sure you have ganache-cli
sudo npm install ganache-cli -g
copy address of first account
$ ganache-cli
Paste this adderess to ui/js/clist.js line 17 https://github.com/sanattaori/techdot/blob/cecabc1917965ed7404e4c444b7572c97e10dcf9/ui/js/clist.js#L17
The Aadhaar based voting system is developed to overcome the flaws of EVM system. So directly EVM will be replaced by touch screen interface having the great user interface and high security.
This project is licensed under the MIT License - see the LICENSE file for details