EvmGas
Gas math for EVM data-carrying value transfers used to anchor payloads.
An anchor transaction is a plain value transfer (to an externally-owned account) carrying the payload as calldata, so its gas cost is the intrinsic transaction cost: 21,000 base gas plus per-byte calldata gas (EIP-2028: 16 gas per non-zero byte, 4 gas per zero byte) - or, since EIP-7623 (Pectra), the calldata floor 21000 + 10 * tokens with tokens = zeroBytes + 4 * nonZeroBytes (40 gas per non-zero byte, 10 per zero byte) when that is larger. A transaction whose gas limit is below max(intrinsic, floor) is invalid, so requiredGas is the minimum limit and what the limit helpers below are built on.
EVM anchor plugins use this for both fee estimation and the actual transaction gas limit instead of a blanket multi-million default, which would grossly over-reserve gas and over-report estimated fees.
Properties
Default safety margin applied on top of the intrinsic gas, in percent.
EIP-7623 floor cost per calldata token.
Calldata cost per non-zero byte (EIP-2028).
Tokens per non-zero calldata byte (EIP-7623); a zero byte is one token.
Base cost of any EVM transaction.
Calldata cost per zero byte.
Functions
EIP-7623 floor: 21000 + 10 * (zeroBytes + 4 * nonZeroBytes).
Exact intrinsic gas for a value transfer carrying data as calldata: 21000 + 16 * nonZeroBytes + 4 * zeroBytes.
Worst-case intrinsic gas for sizeBytes of calldata (every byte assumed non-zero).
The minimum valid gas limit for a value transfer carrying data: the larger of intrinsicGas and calldataFloorGas.
requiredGas for sizeBytes of calldata, every byte assumed non-zero (the worst case).
requiredGas (intrinsic or EIP-7623 floor, whichever is larger) plus a safety margin (default +10%), suitable as the transaction gas limit for an anchor transaction.
Worst-case gas limit (requiredGasForSize) for sizeBytes of calldata plus a safety margin (default +10%).
Applies a percentage safety margin to gas, rounding up.