Open k06a opened 1 year ago
There could be a better API, but currently, the particular value can be taken from the tx trace object.
import {CallItem} from 'hardhat-tracer'
// can be a read call, estimate gas, write tx
await contract.method()
// traverse to the right location in the trace and extract the gasUsed
const trace1 = hre.tracer.lastTrace()!;
const callItem = trace1.top?.children?.[0].children?.[0] as CallItem;
const gasUsed = callItem.params.gasUsed!;
Imagine I wish to check gas_used by 2 traces inside transaction using
v2
?For example, I am writing gas tests for Limit Order Protocol, and wish to check gas used by protocol, so I am going to calculate