Template project for testing smart contracts using hardhat, includes linter, prettier and CI using github actions
The example contract imports openzeppelin standard contracts
During tests chainlink datafeeds are used for validations against contracts calculations that use DEX liquidity pools
Codechecks and Coveralls are also integrated with github actions in order to check and control solidity code coverage and gas costs
pnpm install
Using pnpm run
you can check the commands you will need to test your smart contract and run linter and prettier for solidity or typescript files
If you want to test deployments you have to include your pk on .pk.example and remove the .example
Also edit the deploy.js script and the deploy command to include the network you want to deploy against, this network has to be previously configured in hardhat.config.ts
Check https://hardhat.org/hardhat-runner/docs/guides/deploying if you are lost here
You have to include your API KEY if you desire to test the verification plugin, also you have to configure the networks you want to use, if your constructor receives complex arguments you also will have to create a file Everything is explained here: https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify
We are using the gas reporter included in hardhat and codechecks integration for github actions, for this you have to add your repo here https://app.codechecks.io/, copy the code and add it as a secret for your repository named CC_SECRET, check the codecheks.yml and the .yml for github actions depending on your branch name changes could be needed.
https://github.com/codechecks/docs/blob/master/getting-started.md
Diff parameters can be configured in hardhat.config.ts so will end in a failure if the gas spent rises too much.
You can see the avg column is empty, if you need that include your CMC key in .cmc.example and remove the .example
CI=true in enviroment variables is required so it generates the required json output in gasReporterOutput.json
If you want see previous output locally you have to run pnpm run codechecks
Coveralls integration for github actions is also included, for this you have to add your repo here https://coveralls.io/repos and add a secret for your repository COVERALLS_REPO_TOKEN and set there your repo token, there you will also find a link in order to add your coverage badge in your readme. You can also configure coverage decrease thresholds for failure so if someone ruins the coverage the merge will be blocked.
Locally once you run pnpm run coverage
a report summary will be generated where you can see the % of lines covered for your tests etc, also folder named coverage will be generated with an index.html file inside, if you click it you can check the coverage report similar to the summary you saw after execution but you can also navigate using your browser and check inside each contract which lines are covered which not and how much times each line.