-
Install Node.js packages
$ npm install $ npm install -g hardhat $ npm install -g mocha
-
Create a
.env
file Create a.env
file in the root directory of the project and add the following content:$ cp .env.example .env
Fill in the values for the following variables in the
.env
file:CHAIN_RPC=http://<IP>:8545 ADMIN_KEY=<KEY_TO_CREATE_PRIVATE_KEY> BUILD_PATH=./build # don't need to change if you follow the default contract build path CONTRACT_SOURCE_PATH=./src # don't need to change if you follow the default contract build path CONTRACT_FILENAME=Election.sol # don't need to change if you follow the default contract build path CONTRACT_NAME=ElectionContract # don't need to change if you follow the default contract build path
ADMIN_KEY
should be the same with in the contract.env
file
Should be run in ./contract
directory.
$ npm run compile
$ npm run deploy
Need to run Hardhat node first.
$ npm run hardhat:node
Then compile contract and deploy to Hardhat.
$ npm run hardhat:compile
$ npm run hardhat:deploy
Finally, run Hardhat tests.
$ npm run hardhat:test