Skip to main content

Documentation Index

Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt

Use this file to discover all available pages before exploring further.

Try it Live

Run Transaction examples in the interactive playground

Transaction Types

Complete type definitions for all Ethereum transaction types.

Transaction Type Enum

enum Type {
  Legacy = 0x00,
  EIP2930 = 0x01,
  EIP1559 = 0x02,
  EIP4844 = 0x03,
  EIP7702 = 0x04,
}
Source: types.ts:7-13

Type Definitions

Legacy Transaction (Type 0)

Original Ethereum transaction format with fixed gas price.
type Legacy = {
  type: Type.Legacy       // 0x00
  nonce: bigint
  gasPrice: bigint
  gasLimit: bigint
  to: AddressType | null  // null for contract creation
  value: bigint
  data: Uint8Array
  v: bigint               // EIP-155: chainId or 27/28
  r: Uint8Array           // 32 bytes
  s: Uint8Array           // 32 bytes
}
Key characteristics:
  • Uses v signature component (bigint) instead of yParity
  • Chain ID encoded in v for EIP-155 (v = chainId * 2 + 35 + yParity)
  • Pre-EIP-155 transactions use v = 27 or v = 28
  • No access list support
Source: types.ts:59-72

EIP-2930 Transaction (Type 1)

Access list transactions introduced in Berlin hard fork.
type EIP2930 = {
  type: Type.EIP2930      // 0x01
  chainId: bigint
  nonce: bigint
  gasPrice: bigint
  gasLimit: bigint
  to: AddressType | null
  value: bigint
  data: Uint8Array
  accessList: AccessList
  yParity: number         // 0 or 1
  r: Uint8Array           // 32 bytes
  s: Uint8Array           // 32 bytes
}
Key characteristics:
  • Explicit chainId field
  • Uses yParity (0 or 1) instead of v
  • Includes accessList for pre-declaring account/storage access
  • Still uses fixed gasPrice
Source: types.ts:74-90

EIP-1559 Transaction (Type 2)

Dynamic fee market transactions introduced in London hard fork.
type EIP1559 = {
  type: Type.EIP1559      // 0x02
  chainId: bigint
  nonce: bigint
  maxPriorityFeePerGas: bigint  // Tip for miner
  maxFeePerGas: bigint          // Max total fee willing to pay
  gasLimit: bigint
  to: AddressType | null
  value: bigint
  data: Uint8Array
  accessList: AccessList
  yParity: number         // 0 or 1
  r: Uint8Array           // 32 bytes
  s: Uint8Array           // 32 bytes
}
Key characteristics:
  • Uses maxFeePerGas and maxPriorityFeePerGas instead of fixed gasPrice
  • Effective gas price = min(baseFee + maxPriorityFeePerGas, maxFeePerGas)
  • Includes access list support
  • Most common transaction type on modern Ethereum
Source: types.ts:92-109

EIP-4844 Transaction (Type 3)

Blob transactions for L2 data availability introduced in Dencun hard fork.
type EIP4844 = {
  type: Type.EIP4844      // 0x03
  chainId: bigint
  nonce: bigint
  maxPriorityFeePerGas: bigint
  maxFeePerGas: bigint
  gasLimit: bigint
  to: AddressType      // Cannot be null for blob transactions
  value: bigint
  data: Uint8Array
  accessList: AccessList
  maxFeePerBlobGas: bigint       // Max fee per blob gas
  blobVersionedHashes: readonly VersionedHash[]  // Blob commitments
  yParity: number         // 0 or 1
  r: Uint8Array           // 32 bytes
  s: Uint8Array           // 32 bytes
}
Key characteristics:
  • to cannot be null (no contract creation with blobs)
  • Includes maxFeePerBlobGas for blob gas pricing
  • blobVersionedHashes contains KZG commitments to blob data
  • Each blob is 128 KB (131072 bytes)
  • Maximum 6 blobs per transaction
  • Blob data stored separately from transaction
Source: types.ts:111-130

EIP-7702 Transaction (Type 4)

EOA delegation transactions allowing externally-owned accounts to temporarily act as smart contracts.
type EIP7702 = {
  type: Type.EIP7702      // 0x04
  chainId: bigint
  nonce: bigint
  maxPriorityFeePerGas: bigint
  maxFeePerGas: bigint
  gasLimit: bigint
  to: AddressType | null
  value: bigint
  data: Uint8Array
  accessList: AccessList
  authorizationList: AuthorizationList  // List of delegations
  yParity: number         // 0 or 1
  r: Uint8Array           // 32 bytes
  s: Uint8Array           // 32 bytes
}
Key characteristics:
  • Includes authorizationList for EOA-to-contract delegations
  • Each authorization must be signed by the delegating EOA
  • Allows EOAs to execute contract logic temporarily
  • Delegation is valid only for the transaction duration
Source: types.ts:132-150

Supporting Types

AccessList

Pre-declared account and storage slot access for gas optimization.
type AccessListItem = {
  address: AddressType
  storageKeys: readonly HashType[]
}

type AccessList = readonly AccessListItem[]
Example:
const accessList: AccessList = [
  {
    address: contractAddress,
    storageKeys: [slot1Hash, slot2Hash]
  },
  {
    address: anotherAddress,
    storageKeys: []
  }
]
Source: types.ts:18-26

Authorization

Delegation authorization for EIP-7702 transactions.
type Authorization = {
  chainId: bigint
  address: AddressType      // Contract address to delegate to
  nonce: bigint                // EOA nonce at time of authorization
  yParity: number              // 0 or 1
  r: Uint8Array                // 32 bytes
  s: Uint8Array                // 32 bytes
}

type AuthorizationList = readonly Authorization[]
Example:
const authorization: Authorization = {
  chainId: 1n,
  address: contractAddress,
  nonce: 5n,
  yParity: 0,
  r: signatureR,
  s: signatureS,
}
Source: types.ts:29-43

VersionedHash

KZG commitment hash for EIP-4844 blob transactions.
type VersionedHash = HashType  // 32-byte hash
First byte indicates version (currently 0x01 for SHA-256). Source: types.ts:48

Any Transaction

Union type for all transaction types.
type Any = Legacy | EIP2930 | EIP1559 | EIP4844 | EIP7702
Used in functions that accept any transaction type. Source: types.ts:155

Type Guards

Type guards for runtime type checking.
import {
  isLegacy,
  isEIP2930,
  isEIP1559,
  isEIP4844,
  isEIP7702
} from 'tevm/Transaction'

const tx: Transaction.Any = /* ... */

if (isLegacy(tx)) {
  // tx is Transaction.Legacy
  const v = tx.v
}

if (isEIP1559(tx)) {
  // tx is Transaction.EIP1559
  const maxFee = tx.maxFeePerGas
}

if (isEIP4844(tx)) {
  // tx is Transaction.EIP4844
  const blobs = tx.blobVersionedHashes
}
Type guard implementations:
function isLegacy(tx: Any): tx is Legacy {
  return tx.type === Type.Legacy
}

function isEIP2930(tx: Any): tx is EIP2930 {
  return tx.type === Type.EIP2930
}

function isEIP1559(tx: Any): tx is EIP1559 {
  return tx.type === Type.EIP1559
}

function isEIP4844(tx: Any): tx is EIP4844 {
  return tx.type === Type.EIP4844
}

function isEIP7702(tx: Any): tx is EIP7702 {
  return tx.type === Type.EIP7702
}
Source: typeGuards.ts

Type Comparison

FeatureLegacyEIP-2930EIP-1559EIP-4844EIP-7702
Type byte0x000x010x020x030x04
Chain IDIn vExplicitExplicitExplicitExplicit
Gas pricinggasPricegasPricemaxFee + prioritymaxFee + prioritymaxFee + priority
Access listNoYesYesYesYes
Blob dataNoNoNoYesNo
AuthorizationNoNoNoNoYes
Contract creationYesYesYesNoYes
Signaturev/r/syParity/r/syParity/r/syParity/r/syParity/r/s

Usage Examples

Creating Transactions

import * as Transaction from 'tevm/Transaction'

// Legacy
const legacy: Transaction.Legacy = {
  type: Transaction.Type.Legacy,
  nonce: 0n,
  gasPrice: 20000000000n,
  gasLimit: 21000n,
  to: recipientAddress,
  value: 1000000000000000000n,
  data: new Uint8Array(),
  v: 27n,
  r: signatureR,
  s: signatureS,
}

// EIP-1559
const eip1559: Transaction.EIP1559 = {
  type: Transaction.Type.EIP1559,
  chainId: 1n,
  nonce: 0n,
  maxPriorityFeePerGas: 1000000000n,
  maxFeePerGas: 20000000000n,
  gasLimit: 21000n,
  to: recipientAddress,
  value: 1000000000000000000n,
  data: new Uint8Array(),
  accessList: [],
  yParity: 0,
  r: signatureR,
  s: signatureS,
}

// EIP-4844
const eip4844: Transaction.EIP4844 = {
  type: Transaction.Type.EIP4844,
  chainId: 1n,
  nonce: 0n,
  maxPriorityFeePerGas: 1000000000n,
  maxFeePerGas: 20000000000n,
  gasLimit: 100000n,
  to: recipientAddress,
  value: 0n,
  data: new Uint8Array(),
  accessList: [],
  maxFeePerBlobGas: 1000000000n,
  blobVersionedHashes: [hash1, hash2],
  yParity: 0,
  r: signatureR,
  s: signatureS,
}

Type Narrowing

function processTx(tx: Transaction.Any) {
  switch (tx.type) {
    case Transaction.Type.Legacy:
      // tx is Transaction.Legacy
      console.log('Legacy v:', tx.v)
      break
    case Transaction.Type.EIP1559:
      // tx is Transaction.EIP1559
      console.log('Max fee:', tx.maxFeePerGas)
      break
    case Transaction.Type.EIP4844:
      // tx is Transaction.EIP4844
      console.log('Blobs:', tx.blobVersionedHashes.length)
      break
  }
}