alloy_eip8141/constants.rs
1//! [EIP-8141] constants.
2//!
3//! [EIP-8141]: https://eips.ethereum.org/EIPS/eip-8141
4
5use alloy_primitives::{Address, U256, hex};
6
7/// Identifier for EIP-8141 frame transactions.
8pub const FRAME_TX_TYPE: u8 = 0x06;
9
10/// Intrinsic gas cost for an EIP-8141 frame transaction.
11pub const FRAME_TX_INTRINSIC_COST: u64 = 12_000;
12
13/// Fixed gas cost charged per frame.
14pub const FRAME_TX_PER_FRAME_COST: u64 = 475;
15
16/// Cost of a nonzero-value frame with an explicit target other than the sender.
17///
18/// This is EIP-2780's `TX_VALUE_COST`, referenced by EIP-8141.
19pub const TX_VALUE_COST: u64 = 6_000;
20
21/// Standard gas charged per frame transaction calldata token.
22///
23/// This matches `GasCosts.TX_DATA_TOKEN_STANDARD` in the execution-specs EIP-8141 draft.
24pub const FRAME_TX_DATA_TOKEN_STANDARD_COST: u64 = 4;
25
26/// Total-cost floor charged per frame transaction calldata token.
27///
28/// EIP-7976 raises this from 10 to 16 and counts every calldata byte as four
29/// floor tokens, producing a uniform 64 gas floor per byte.
30pub const FRAME_TX_TOTAL_COST_FLOOR_PER_TOKEN: u64 = 16;
31
32/// Protocol entry point caller used by `DEFAULT` and `VERIFY` frames.
33pub const ENTRY_POINT: Address = Address::new(hex!("00000000000000000000000000000000000000aa"));
34
35/// Address of the canonical expiry verifier.
36pub const EXPIRY_VERIFIER: Address = Address::new(hex!("0000000000000000000000000000000000008141"));
37
38/// Calldata length, in bytes, for expiry verifier frames.
39pub const EXPIRY_DATA_LENGTH: usize = 8;
40
41/// Maximum number of frames in a frame transaction.
42pub const MAX_FRAMES: usize = 64;
43
44/// Order of the secp256k1 curve used by EIP-8141 signatures.
45pub const SECP256K1N: U256 =
46 U256::from_be_bytes(hex!("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"));
47
48/// Order of the NIST P-256 curve used by EIP-8141 signatures.
49pub const SECP256R1N: U256 =
50 U256::from_be_bytes(hex!("ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"));
51
52/// Byte length of a secp256k1 signature entry: `v || r || s`.
53pub const SECP256K1_SIGNATURE_LENGTH: usize = 65;
54
55/// Byte length of a P-256 signature entry: `r || s || qx || qy`.
56pub const P256_SIGNATURE_LENGTH: usize = 128;
57
58/// Maximum validation work for public mempool admission.
59pub const MAX_VERIFY_GAS: u64 = 100_000;
60
61/// Maximum state gas budget across a public-mempool validation prefix.
62pub const MAX_VERIFY_STATE_GAS: u64 = 500_000;
63
64/// Maximum pending public-mempool transactions using any non-canonical paymaster.
65pub const MAX_PENDING_TXS_USING_NON_CANONICAL_PAYMASTER: usize = 1;
66
67/// Canonical expiry verifier runtime bytecode.
68pub const EXPIRY_VERIFIER_RUNTIME: [u8; 26] =
69 hex!("60083614600a575f5ffd5b5f3560c01c4211601657005b5f5ffd");
70
71/// Approval flag mask for extracting the allowed approval scope from frame flags.
72pub const APPROVE_SCOPE_MASK: u8 = 0x03;
73
74/// Atomic batch frame flag.
75pub const ATOMIC_BATCH_FLAG: u8 = 0x04;
76
77/// Mask of all currently defined frame flag bits.
78pub const FRAME_FLAGS_MASK: u8 = APPROVE_SCOPE_MASK | ATOMIC_BATCH_FLAG;