EEVM.Context.Transaction (eevm v0.1.0)

Copy Markdown View Source

Transaction-level context — information about the original transaction exposed to the EVM via environment opcodes.

Fields

FieldOpcodeDescription
originORIGIN (0x32)The externally owned account (EOA) that signed the tx
gaspriceGASPRICE (0x3A)Gas price in wei the sender is paying
blob_hashesBLOBHASH (0x49)List of blob versioned hashes from EIP-4844 transaction payload
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. caller (in EEVM.Context.Contract) is the direct caller of the current frame and changes with each CALL.

Summary

Functions

Creates a new transaction context with default values.

Creates a new transaction context with the given overrides.

Types

authorization()

@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()
}

t()

@type t() :: %EEVM.Context.Transaction{
  access_list: [{non_neg_integer(), [non_neg_integer()]}],
  authorization_list: [authorization()],
  blob_hashes: [non_neg_integer()],
  data: binary(),
  gas_limit: non_neg_integer(),
  gasprice: 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()
}

Functions

new()

@spec new() :: t()

Creates a new transaction context with default values.

new(opts)

@spec new(keyword()) :: t()

Creates a new transaction context with the given overrides.

Example

iex> tx = EEVM.Context.Transaction.new(origin: 0xDEAD, gasprice: 20_000_000_000)
iex> tx.origin
0xDEAD