The transaction environment code executes in: the signed transaction as
the EVM sees it. EEVM.transact/4 builds one from the wire transaction.
Set it yourself to give bytecode run with EEVM.run/2 a transaction
context, through its :tx option, or to simulate a transaction from any
address: EEVM.transact/4 also takes an unsigned TxEnv and treats its
origin as the sender, without a signature. Set gas_price for a
legacy or EIP-2930 type, and the max_* fee fields for the others.
Fields
| Field | Opcode | Description |
|---|---|---|
type | — | :legacy, :eip2930, :eip1559, :eip4844, or :eip7702 |
origin | ORIGIN (0x32) | The externally owned account (EOA) that signed the tx, or the impersonated sender |
gas_price | GASPRICE (0x3A) | Effective gas price in wei the sender pays |
nonce | — | The sender's nonce |
gas_limit | — | The transaction's gas limit |
to | — | The recipient address, or nil for a contract creation |
value | — | Wei sent with the call |
data | — | Calldata, or initcode for a creation |
max_fee_per_gas, max_priority_fee_per_gas | — | EIP-1559 fee caps in wei |
max_fee_per_blob_gas | — | EIP-4844 blob fee cap in wei |
blob_hashes | BLOBHASH (0x49) | List of blob versioned hashes from EIP-4844 transaction payload |
access_list | — | EIP-2930 [{address, [slot]}] warmed before execution |
authorization_list | — | EIP-7702 authorizations applied before execution |
Origin vs Caller
origin is always the EOA that signed the transaction — it never changes,
even through nested contract calls. The caller (CALLER, and EEVM.run/2's
:caller option) is the direct caller of the current frame and changes
with each CALL.
Summary
Types
@type authorization() :: %{ chain_id: non_neg_integer(), address: non_neg_integer(), nonce: non_neg_integer(), y_parity: 0..255, r: non_neg_integer(), s: non_neg_integer() }
@type t() :: %EEVM.TxEnv{ access_list: [{non_neg_integer(), [non_neg_integer()]}], authorization_list: [authorization()], blob_hashes: [non_neg_integer()], data: binary(), gas_limit: non_neg_integer(), gas_price: non_neg_integer(), max_fee_per_blob_gas: non_neg_integer(), max_fee_per_gas: non_neg_integer(), max_priority_fee_per_gas: non_neg_integer(), nonce: non_neg_integer(), origin: non_neg_integer(), to: non_neg_integer() | nil, type: :legacy | :eip2930 | :eip1559 | :eip4844 | :eip7702, value: non_neg_integer() }