Skip to content

Displaying execution traces

Hardhat can display execution traces of your contracts when running tests, scripts, and tasks. This can be helpful for debugging and understanding the behavior of your contracts.

The --verbosity (or -v, -vv, -vvv, etc.) Global Option controls the amount of output shown during test execution, script runs, and deployments when using simulated networks.

Higher verbosity levels show more information in the execution traces, and display traces for more types of operations.

To try it out, run your tests with a higher verbosity level:

Terminal window
npx hardhat test -vvv

You can also use the long form:

Terminal window
npx hardhat test --verbosity 3

Understanding the different verbosity levels

Section titled “Understanding the different verbosity levels”

The verbosity levels behave slightly differently for Solidity tests and TypeScript tests, scripts, and tasks, but you can expect similar results for most cases. Read this section to understand the details of what each level shows in different contexts.

Each level includes everything from the previous levels:

LevelWhat it adds
0Test names and pass/fail status (failure details are always shown)
1Decoded logs for failing tests
2Decoded logs for passing tests (default)
3Execution traces for failing tests; stack traces always collected
4Execution traces for passing tests; setup traces for failing tests
5Setup traces for passing tests

In this case, the --verbosity flag controls which execution traces are shown for the different JSON-RPC calls made to your simulated network.

LevelWhat it shows
0 - 2No execution traces (default)
3Execution traces for failing transactions only
4Execution traces for all transactions
5All execution traces with no deduplication (shows gas estimations, repeated polling, etc.)