Demo with ganache-cli, nodejs, api's to call the contract function and react frontend. We can vote for 'Ethereum' or 'Hyperledger fabric' on the frontend. This demo is just to illustrate how to interact with the ethereum blockchain network (ganache-cli), a server and a frontend.
You'll need ganache-cli for this to work.
- Install all npm packages by invoking
npm install
- Navigate to the front end
cd react-frontend
- Install the frontend npm packages
npm install
- Go back to your main folder
cd ../..
- Start ganache-cli by invoking
ganache-cli
- In a new console, go to /src/truffle
cd src/truffle
- Deploy your contracts
truffle migrate --reset
- Go back to your main folder
cd ../..
- Use
yarn dev
to start the react frontend app to interact with the nodejs server. Don't start the nodejs and react seperately
- Install all npm packages by invoking
npm install
- Start ganache-cli by invoking
ganache-cli
- In a new console, go to /src/truffle
cd src/truffle
- Deploy your contracts
truffle migrate --reset
- Go back to your main folder
cd ../..
- Start the server by
npm start
- Browse to
http://localhost:3100/api/ballot
for the winning result - Browse to
http://localhost:3100/api/accounts
for all the accounts on the network - Post to
http://localhost:3100/api/ballot/vote/{number}
to vote for a ballot (0 or 1)