Initial basic app using truffle.js framework for election/voting with solidity contracts.
http://www.dappuniversity.com/articles/the-ultimate-ethereum-dapp-tutorial
- Install the truffle framework
npm install -g truffle - Install the ganache gui or cli
npm install -g ganache-cli git clone https://github.com/giancarlopetrini/voting-dapp && cd voting-dapp && npm install- In the background, simply run
ganache-cli, the accounts/private keys will be generated and an in memory ETH blockchain will start.
- To add aditional tests, edit the
test/election.jsfile. - From project root (make sure ganache-cli is running) run
truffle test. If all passes, you're ready to deploy.
- The deploy methods have been added to
/migrations/and will be run in the order specified. e.g.1_ 2_ .... To deploy (run a migration), from project root, runtuffle migrate. - If making changes to existing contracts, like adding an additional struct to a function that's been deployed, you'll need to run
truffle migrate -resetfor it work properly.
npm run devfrom project root will openlocalhost:3000.
- Ensure Metamask is installed, and pop ups are not blocked. Within Metamask, click your accounts' icon to access the menu, and select
import account. - Copy one of the seeds that
ganache-clispit out upon starting it and paste it into Metamask. You've now loaded your Ethers in Metamask. - Make a candidate selection and vote. Your results should be displayed. Continue, importing other accounts, as needed.