Before running any command, you need to create a .env
file and set a BIP-39 compatible mnemonic as an environment
variable. Follow the example in .env.example
. If you don't already have a mnemonic, use this website to generate one.
Then, proceed with installing dependencies:
yarn install
yarn add hardhat
yarn add hardhat-docgen
Compile the smart contracts with Hardhat:
$ npx hardhat compile
Compile the smart contracts and generate TypeChain artifacts:
$ yarn run typechain
Lint the Solidity code:
$ yarn lint:sol
Lint the TypeScript code:
$ yarn lint:ts
Run the Mocha tests:
$ npx hardhat test
Generate the code coverage report:
$ yarn add hardhat-coverage
$ npx hardhat coverage --testfiles "./test"
Delete the smart contract artifacts, the coverage reports and the Hardhat cache:
$ npx hardhat clean
Deploy the contracts to Rinkeby Network:
Token Contract
$ npx hardhat deploy:Token --network rinkeby
Factory Contract
$ npx hardhat deploy:Factory --network rinkeby
Verify the contracts on Etherscan programatically:
Token Contract
$ npx hardhat verify <address_of_the_deployed_token_contract> --network rinkeby <name_of_the_token> <symbol_of_the_token>
Factory Contract
$ npx hardhat verify <address_of_the_deployed_factory_contract> --network rinkeby
If you use VSCode, you can enjoy syntax highlighting for your Solidity code via the hardhat-vscode extension.