gas

package
v0.117.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const EIP7825MaxTxGasLimit = uint64(16_777_216)

EIP7825MaxTxGasLimit is the EIP-7825 per-transaction gas limit cap (2^24). Used as a reference value in docs and tests; YAML max_tx_gas_limit accepts any uint64.

Variables

This section is empty.

Functions

func ApplyDefaults

func ApplyDefaults(ctx context.Context, client Client, opts *bind.TransactOpts, cfg Config) error

ApplyDefaults applies configured default gas limit and price settings to opts. When DefaultGasPriceWei is set, the latest block header is inspected to choose EIP-1559 vs legacy. DefaultGasLimit is capped by MaxTxGasLimit when both are set.

func CapGasLimit

func CapGasLimit(gas, maxTxGas uint64) uint64

CapGasLimit returns gas unchanged when maxTxGas is 0; otherwise returns min(gas, maxTxGas).

func IsEIP1559Header

func IsEIP1559Header(header *types.Header) bool

IsEIP1559Header reports whether the header indicates EIP-1559 support.

Types

type Client

type Client interface {
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
	SuggestGasTipCap(ctx context.Context) (*big.Int, error)
}

Client exposes the RPC methods required to apply gas price defaults.

type Config

type Config struct {
	// DefaultGasLimit sets opts.GasLimit on the chain deployer when non-zero.
	DefaultGasLimit uint64 `yaml:"default_gas_limit,omitempty" json:"defaultGasLimit,omitempty"`
	// DefaultGasPriceWei sets legacy gasPrice on pre-EIP-1559 chains, or maxFeePerGas
	// (GasFeeCap) on EIP-1559 chains, in wei.
	DefaultGasPriceWei uint64 `yaml:"default_gas_price_wei,omitempty" json:"defaultGasPriceWei,omitempty"`
	// DefaultGasTipCapWei sets maxPriorityFeePerGas (GasTipCap) on EIP-1559 chains only, in wei.
	// Only applied when DefaultGasPriceWei is also set. When unset, the node suggestion is used.
	// The tip is capped so feeCap >= baseFee + tip.
	DefaultGasTipCapWei uint64 `yaml:"default_gas_tip_cap_wei,omitempty" json:"defaultGasTipCapWei,omitempty"`
	// MaxTxGasLimit caps gas when non-zero: min(value, max_tx_gas_limit) on default_gas_limit
	// (deployer key) and on eth_estimateGas results from the chain client.
	MaxTxGasLimit uint64 `yaml:"max_tx_gas_limit,omitempty" json:"maxTxGasLimit,omitempty"`
}

Config holds per-chain default gas settings applied to the chain deployer at load time. These defaults apply to any code path that uses chain.DeployerKey (bind, gobindings, etc.).

zkSync VM chains: defaults are applied to DeployerKey (bind/gobind writes, etc.). Contract deploys on zkSync use DeployerKeyZkSyncVM with SDK fee estimation instead, so gas_config does not affect the operations contract deploy path on those chains.

Configure under a network entry's metadata block in .config/networks/*.yaml:

metadata:
  gas_config:
    default_gas_limit: 7500000
    default_gas_price_wei: 210000000000
    default_gas_tip_cap_wei: 40000000000  # optional EIP-1559 tip override
    max_tx_gas_limit: 16777216           # optional cap on deployer limit and eth_estimateGas (e.g. EIP-7825)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL