gas-forecaster

A CLI tool for forecasting smart contract deployment and transaction costs in USD across multiple EVM networks.


Usage

The tool has three main commands: deploy, call, and report.

deploy

Forecasts the cost to deploy a contract.


# Forecast deployment across default networks (ETH, Polygon, Arbitrum, Optimism, BSC)
gas-forecaster deploy ./contracts/MyNFT.sol

# Specify networks and constructor arguments
gas-forecaster deploy ./contracts/MyToken.sol --networks ethereum,base --args "My Token" "TKN" 18 1000000
                    

call

Forecasts the cost to call a specific function on a contract.


# Forecast a simple transfer call
gas-forecaster call ./contracts/MyToken.sol --function transfer --args 0xAb58... 1000000000000000000
                    

report (Pro Feature)

Generates a comprehensive gas report for every function in a contract, using a local Anvil node for simulation.


# Generate a full report using Ethereum for price estimates
gas-forecaster report ./contracts/MyNFT.sol --network ethereum
                    

Options

  • --networks <NETWORKS>: A comma-separated list of networks to run the forecast on. Defaults to ethereum,polygon,arbitrum,optimism,bsc.
  • --api-key <KEY>: Your Alchemy API key. Can also be set via the ALCHEMY_API_KEY environment variable or config file.
  • --budget <USD_AMOUNT>: (Pro Feature) Sets a deployment budget in USD. The command will exit with an error if the estimated cost on any network exceeds this budget, making it useful for CI/CD pipelines.
  • --args <ARGS>: A space-separated list of arguments for the function or constructor.