Prerequisites: install Node.js 22.10+ with pnpm and Visual Studio Code.
Open the root of the project using Visual Studio Code and install all the extensions recommended by notifications of Visual Studio Code, then restart Visual Studio Code.
Open the terminal and run the command below to install all the dependencies and prepare the project:
pnpm iRun to view commands:
pnpm runpnpm coverageshows all coverage andpnpm testruns all Hardhat and Foundry tests.pnpm testh:vvv test/SomeContract.tsandpnpm testf -vvv --mc SomeContractTestsshow details about events, calls, gas costs, etc.pnpm coveragef:sumshow a coverage summary with branches for Foundry.
The project can properly work without the `.env` file, but supports some variables (see .env.details for details). For example:
BAIL=trueto stop tests on the first failure.EVM_VERSION="default"andHARDFORK="default"if you would not like to use Prague, but would like Hardhat to behave by default.VIA_IR=falseto disable IR optimization. You may also need to disable it in.solcover.jsif compilation issues when running coverage.COINMARKETCAP_API_KEYandETHERSCAN_API_KEYif you would like to see gas costs in dollars when runningpnpm testh:gas.
-
The
Watchbutton can show/hide highlighting of the code coverage in the contract files after runningpnpm coverage. The button is in the lower left corner of the VS Code window and added byryanluker.vscode-coverage-gutters. -
Open the context menu (right-click) in a contract file, after running
pnpm coverage, and select "Coverage Gutters: Preview Coverage Report" (or press Ctrl+Shift+6) to open the coverage HTML page directly in VS Code. -
Start writing
ssin Solidity or TypeScript files to see some basic snippets.
Run to clean up the project:
pnpm run cleanAfterwards, try again.