Skip to main content

Overview

GasConstants provides comprehensive EVM gas cost constants and calculation functions according to the Ethereum Yellow Paper and various EIPs. Use this module to accurately compute gas costs for opcodes, storage operations, transactions, precompiles, and memory expansion.

Basic Opcode Costs

Step-based gas costs for EVM opcodes:

Hashing Operations

Storage Operations (EIP-2929, EIP-2200, EIP-3529)

Storage operations have different costs based on access patterns:

Memory Expansion

Memory costs grow quadratically with size:

Transaction Costs

Contract Creation and Calls

Logging Operations

Copy Operations

EIP-4844: Blob Transactions

EIP-1153: Transient Storage

Refund Calculation

Hardfork Utilities

Check EIP activation status:
Get hardfork-specific costs:

Precompile Gas Costs

The Precompile namespace contains all precompile gas constants and calculation functions:

ECRECOVER, SHA256, RIPEMD160, IDENTITY

MODEXP (EIP-2565)

BN254 (alt_bn128) - Hardfork-dependent

BLAKE2F

Point Evaluation (EIP-4844)

BLS12-381 (EIP-2537 - Prague)

Complete Gas Constants Reference

Basic Operations

Hashing

Storage

Logging

Calls and Creates

Memory

Transactions

EIP-4844 Blobs

EIP-1153 Transient Storage