/gas-report — Gas Cost Analysis
Run the full gas analysis pipeline for SaThuCoin and produce a clear summary.
Steps
- •Run
npm run compileto ensure contracts are compiled - •Run
npm run test:gas(setsREPORT_GAS=trueand runs all tests) - •Run
npm run sizeto get contract size information
Output Requirements
Produce a structured summary with:
Per-Function Gas Costs
For each contract function (mint, mintForDeed, transfer, transferFrom, approve), report:
- •Min / Avg / Max gas usage
- •Number of calls observed during tests
Contract Size
- •Report contract size in kB from
hardhat-contract-sizeroutput - •Base chain contract size limit is 24.576 kB (same as Ethereum)
- •Flag if the contract exceeds 80% of the limit (>19.66 kB)
Cost Estimates
Using approximate Base chain gas prices:
- •Base L2 execution gas: ~0.001 gwei (very cheap)
- •L1 data fee: dominant cost, varies with Ethereum gas prices
- •Provide rough USD estimates if possible, noting they vary with L1 gas
Optimization Notes
Highlight any of the following if observed:
- •Functions exceeding 100,000 gas
- •Significant variance between min and max (indicates input-dependent cost)
- •The
deedstring parameter inmintForDeed— note that longer strings cost more gas due to calldata - •Optimizer is set to 200 runs — note tradeoff (lower runs = cheaper deploy, higher runs = cheaper execution)
Key Context
- •Contract:
contracts/SaThuCoin.sol(ERC20 + Ownable, 49 lines) - •Optimizer: enabled, 200 runs (configured in
hardhat.config.js) - •
hardhat-gas-reporteris bundled with@nomicfoundation/hardhat-toolbox - •
hardhat-contract-sizeris installed as a devDependency