Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/GasConstants / Precompile

Precompile

Variables

blake2f()

const blake2f: (rounds) => bigint = calculateBlake2fCost
Defined in: src/primitives/GasConstants/Precompile.js:285 Convenience alias for BLAKE2F cost calculation Calculate BLAKE2F precompile cost

Parameters

rounds
bigint Number of compression rounds

Returns

bigint Gas cost

Param

Number of compression rounds

Returns

Gas cost

Blake2fPerRound

const Blake2fPerRound: 1n = 1n
Defined in: src/primitives/GasConstants/Precompile.js:268 BLAKE2F (address 0x09) - Cost per round

Bls12G1Add

const Bls12G1Add: 500n = 500n
Defined in: src/primitives/GasConstants/Precompile.js:310 BLS12_G1ADD (address 0x0b) - Fixed cost

Bls12G1MsmBase

const Bls12G1MsmBase: 12000n = 12000n
Defined in: src/primitives/GasConstants/Precompile.js:322 BLS12_G1MSM (address 0x0d) - Base cost per point

Bls12G1Mul

const Bls12G1Mul: 12000n = 12000n
Defined in: src/primitives/GasConstants/Precompile.js:316 BLS12_G1MUL (address 0x0c) - Fixed cost

Bls12G2Add

const Bls12G2Add: 800n = 800n
Defined in: src/primitives/GasConstants/Precompile.js:328 BLS12_G2ADD (address 0x0e) - Fixed cost

Bls12G2MsmBase

const Bls12G2MsmBase: 45000n = 45000n
Defined in: src/primitives/GasConstants/Precompile.js:340 BLS12_G2MSM (address 0x10) - Base cost per point

Bls12G2Mul

const Bls12G2Mul: 45000n = 45000n
Defined in: src/primitives/GasConstants/Precompile.js:334 BLS12_G2MUL (address 0x0f) - Fixed cost

Bls12MapFp2ToG2

const Bls12MapFp2ToG2: 75000n = 75000n
Defined in: src/primitives/GasConstants/Precompile.js:364 BLS12_MAP_FP2_TO_G2 (address 0x13) - Fixed cost

Bls12MapFpToG1

const Bls12MapFpToG1: 5500n = 5500n
Defined in: src/primitives/GasConstants/Precompile.js:358 BLS12_MAP_FP_TO_G1 (address 0x12) - Fixed cost

Bls12PairingBase

const Bls12PairingBase: 65000n = 65000n
Defined in: src/primitives/GasConstants/Precompile.js:346 BLS12_PAIRING (address 0x11) - Base cost

Bls12PairingPerPair

const Bls12PairingPerPair: 43000n = 43000n
Defined in: src/primitives/GasConstants/Precompile.js:352 BLS12_PAIRING - Per-pair cost

EcAddByzantium

const EcAddByzantium: 500n = 500n
Defined in: src/primitives/GasConstants/Precompile.js:154 BN254 ECADD - Byzantium to Berlin

EcAddIstanbul

const EcAddIstanbul: 150n = 150n
Defined in: src/primitives/GasConstants/Precompile.js:148 BN254 ECADD (address 0x06) - Istanbul onwards

EcMulByzantium

const EcMulByzantium: 40000n = 40000n
Defined in: src/primitives/GasConstants/Precompile.js:166 BN254 ECMUL - Byzantium to Berlin

EcMulIstanbul

const EcMulIstanbul: 6000n = 6000n
Defined in: src/primitives/GasConstants/Precompile.js:160 BN254 ECMUL (address 0x07) - Istanbul onwards

EcPairingBaseByzantium

const EcPairingBaseByzantium: 100000n = 100000n
Defined in: src/primitives/GasConstants/Precompile.js:184 BN254 ECPAIRING - Base cost (Byzantium to Berlin)

EcPairingBaseIstanbul

const EcPairingBaseIstanbul: 45000n = 45000n
Defined in: src/primitives/GasConstants/Precompile.js:172 BN254 ECPAIRING (address 0x08) - Base cost (Istanbul onwards)

EcPairingPerPairByzantium

const EcPairingPerPairByzantium: 80000n = 80000n
Defined in: src/primitives/GasConstants/Precompile.js:190 BN254 ECPAIRING - Per-pair cost (Byzantium to Berlin)

EcPairingPerPairIstanbul

const EcPairingPerPairIstanbul: 34000n = 34000n
Defined in: src/primitives/GasConstants/Precompile.js:178 BN254 ECPAIRING - Per-pair cost (Istanbul onwards)

EcRecover

const EcRecover: 3000n = 3000n
Defined in: src/primitives/GasConstants/Precompile.js:11 ECRECOVER (address 0x01) - Fixed cost

IdentityBase

const IdentityBase: 15n = 15n
Defined in: src/primitives/GasConstants/Precompile.js:63 IDENTITY (address 0x04) - Base cost

IdentityWord

const IdentityWord: 3n = 3n
Defined in: src/primitives/GasConstants/Precompile.js:69 IDENTITY - Per-word cost

ModExpLinearThreshold

const ModExpLinearThreshold: 1024n = 1024n
Defined in: src/primitives/GasConstants/Precompile.js:98 MODEXP - Linear threshold (1024 bytes)

ModExpMin

const ModExpMin: 200n = 200n
Defined in: src/primitives/GasConstants/Precompile.js:86 MODEXP (address 0x05) - Minimum cost (EIP-2565)

ModExpQuadraticThreshold

const ModExpQuadraticThreshold: 64n = 64n
Defined in: src/primitives/GasConstants/Precompile.js:92 MODEXP - Quadratic threshold (64 bytes)

PointEvaluation

const PointEvaluation: 50000n = 50000n
Defined in: src/primitives/GasConstants/Precompile.js:291 POINT_EVALUATION (address 0x0a) - Fixed cost (EIP-4844)

Ripemd160Base

const Ripemd160Base: 600n = 600n
Defined in: src/primitives/GasConstants/Precompile.js:40 RIPEMD160 (address 0x03) - Base cost

Ripemd160Word

const Ripemd160Word: 120n = 120n
Defined in: src/primitives/GasConstants/Precompile.js:46 RIPEMD160 - Per-word cost

Sha256Base

const Sha256Base: 60n = 60n
Defined in: src/primitives/GasConstants/Precompile.js:17 SHA256 (address 0x02) - Base cost

Sha256Word

const Sha256Word: 12n = 12n
Defined in: src/primitives/GasConstants/Precompile.js:23 SHA256 - Per-word cost

Functions

calculateBlake2fCost()

calculateBlake2fCost(rounds): bigint
Defined in: src/primitives/GasConstants/Precompile.js:276 Calculate BLAKE2F precompile cost

Parameters

rounds
bigint Number of compression rounds

Returns

bigint Gas cost

calculateBls12G1MsmCost()

calculateBls12G1MsmCost(pairCount): bigint
Defined in: src/primitives/GasConstants/Precompile.js:403 Calculate BLS12_G1MSM precompile cost

Parameters

pairCount
bigint Number of point-scalar pairs

Returns

bigint Gas cost

calculateBls12G2MsmCost()

calculateBls12G2MsmCost(pairCount): bigint
Defined in: src/primitives/GasConstants/Precompile.js:416 Calculate BLS12_G2MSM precompile cost

Parameters

pairCount
bigint Number of point-scalar pairs

Returns

bigint Gas cost

calculateBls12PairingCost()

calculateBls12PairingCost(pairCount): bigint
Defined in: src/primitives/GasConstants/Precompile.js:429 Calculate BLS12_PAIRING precompile cost

Parameters

pairCount
bigint Number of G1-G2 pairs

Returns

bigint Gas cost

calculateEcPairingCost()

calculateEcPairingCost(pairCount, hardfork): bigint
Defined in: src/primitives/GasConstants/Precompile.js:205 Calculate ECPAIRING precompile cost

Parameters

pairCount
bigint Number of point pairs
hardfork
Hardfork EVM hardfork

Returns

bigint Gas cost

Example

const cost = calculateEcPairingCost(2n, 'istanbul');
// 45000 + (2 * 34000) = 113000 gas

calculateIdentityCost()

calculateIdentityCost(dataSize): bigint
Defined in: src/primitives/GasConstants/Precompile.js:77 Calculate IDENTITY precompile cost

Parameters

dataSize
bigint Size of data in bytes

Returns

bigint Gas cost

calculateModExpCost()

calculateModExpCost(baseLength, expLength, modLength, expHead): bigint
Defined in: src/primitives/GasConstants/Precompile.js:126 Calculate MODEXP precompile cost

Parameters

baseLength
bigint Length of base in bytes
expLength
bigint Length of exponent in bytes
modLength
bigint Length of modulus in bytes
expHead
bigint First 32 bytes of exponent

Returns

bigint Gas cost

calculatePointEvaluationCost()

calculatePointEvaluationCost(): bigint
Defined in: src/primitives/GasConstants/Precompile.js:298 Calculate POINT_EVALUATION precompile cost

Returns

bigint Gas cost (fixed at 50000)

calculateRipemd160Cost()

calculateRipemd160Cost(dataSize): bigint
Defined in: src/primitives/GasConstants/Precompile.js:54 Calculate RIPEMD160 precompile cost

Parameters

dataSize
bigint Size of data in bytes

Returns

bigint Gas cost

calculateSha256Cost()

calculateSha256Cost(dataSize): bigint
Defined in: src/primitives/GasConstants/Precompile.js:31 Calculate SHA256 precompile cost

Parameters

dataSize
bigint Size of data in bytes

Returns

bigint Gas cost

ecPairingCost()

ecPairingCost(this): bigint
Defined in: src/primitives/GasConstants/Precompile.js:260 Calculate ECPAIRING precompile cost (convenience form with this:)

Parameters

this
hardfork
Hardfork
pairCount
bigint

Returns

bigint

getEcAddCost()

getEcAddCost(hardfork): bigint
Defined in: src/primitives/GasConstants/Precompile.js:226 Get ECADD cost for hardfork

Parameters

hardfork
Hardfork EVM hardfork

Returns

bigint Gas cost

getEcMulCost()

getEcMulCost(hardfork): bigint
Defined in: src/primitives/GasConstants/Precompile.js:243 Get ECMUL cost for hardfork

Parameters

hardfork
Hardfork EVM hardfork

Returns

bigint Gas cost