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
New to transactions? Start with Transaction Fundamentals to learn about transaction types, lifecycle, signing, and gas mechanics.
Complete Ethereum transaction implementation supporting all transaction types from Legacy to EIP-7702.
Overview
Transaction module provides type-safe encoding, decoding, signing, and hashing for all Ethereum transaction types. Supports Legacy (Type 0), EIP-2930 (Type 1), EIP-1559 (Type 2), EIP-4844 (Type 3), and EIP-7702 (Type 4) transactions with full RLP serialization.
Quick Start
Basic Usage
Type-Specific Operations
Utilities
import * as Transaction from 'tevm/Transaction'
import * as Address from 'tevm/Address'
// Create a transaction
const tx : Transaction . EIP1559 = {
type: Transaction . Type . EIP1559 ,
chainId: 1 n ,
nonce: 0 n ,
maxPriorityFeePerGas: 1000000000 n ,
maxFeePerGas: 20000000000 n ,
gasLimit: 21000 n ,
to: addressBytes ,
value: 1000000000000000000 n ,
data: new Uint8Array (),
accessList: [],
yParity: 0 ,
r: signatureR ,
s: signatureS ,
}
// Serialize to bytes
const serialized = Transaction . serialize ( tx )
// Compute transaction hash
const hash = Transaction . hash ( tx )
// Get signing hash
const signingHash = Transaction . getSigningHash ( tx )
// Recover sender from signature
const sender = Transaction . getSender ( tx )
// Deserialize from bytes
const decoded = Transaction . deserialize ( serialized )
// Detect transaction type from bytes
const type = Transaction . detectType ( serialized )
import * as Transaction from 'tevm/Transaction'
// Legacy transaction
const legacy : Transaction . Legacy = {
type: Transaction . Type . Legacy ,
nonce: 0 n ,
gasPrice: 20000000000 n ,
gasLimit: 21000 n ,
to: addressBytes ,
value: 1000000000000000000 n ,
data: new Uint8Array (),
v: 27 n ,
r: signatureR ,
s: signatureS ,
}
// Get chain ID from legacy v value
const chainId = Transaction . getChainId ( legacy )
// EIP-1559 transaction
const eip1559 : Transaction . EIP1559 = { /* ... */ }
const effectiveGasPrice = Transaction . EIP1559 . getEffectiveGasPrice (
eip1559 ,
baseFee
)
// EIP-4844 blob transaction
const eip4844 : Transaction . EIP4844 = {
type: Transaction . Type . EIP4844 ,
chainId: 1 n ,
nonce: 0 n ,
maxPriorityFeePerGas: 1000000000 n ,
maxFeePerGas: 20000000000 n ,
gasLimit: 100000 n ,
to: addressBytes ,
value: 0 n ,
data: new Uint8Array (),
accessList: [],
maxFeePerBlobGas: 1000000000 n ,
blobVersionedHashes: [ hash1 , hash2 ],
yParity: 0 ,
r: signatureR ,
s: signatureS ,
}
const blobCost = Transaction . EIP4844 . getBlobGasCost ( eip4844 , blobBaseFee )
import * as Transaction from 'tevm/Transaction'
// Format for display
const formatted = Transaction . format ( tx )
// "EIP-1559 tx to 0x..., value: 1 ETH, nonce: 0"
// Get gas price (handles all types)
const gasPrice = Transaction . getGasPrice ( tx , baseFee )
// Check if transaction has access list
if ( Transaction . hasAccessList ( tx )) {
const accessList = Transaction . getAccessList ( tx )
}
// Get chain ID
const chainId = Transaction . getChainId ( tx )
// Check if signed
if ( Transaction . isSigned ( tx )) {
const sender = Transaction . getSender ( tx )
}
// Assert signed (throws if not)
Transaction . assertSigned ( tx )
// Verify signature
const isValid = Transaction . verifySignature ( tx )
Effect Schema
import { TransactionSchema } from '@tevm/voltaire/Transaction/effect'
// From RPC (legacy)
const tx = TransactionSchema . fromRpc ({ type: '0x0' , nonce: '0x0' , gas: '0x5208' , to: '0x' + '11' . repeat ( 20 ), value: '0x0' , data: '0x' })
const hash = tx . hash ()
const serialized = tx . serialize ()
Quick Reference
Core Operations
Method Description serialize(tx)RLP encode to bytes deserialize(data)RLP decode from bytes detectType(data)Detect type from serialized bytes hash(tx)Compute transaction hash getSigningHash(tx)Get hash to sign
Signature Operations
Method Description getSender(tx)Recover sender address verifySignature(tx)Validate signature isSigned(tx)Check if signed assertSigned(tx)Assert signed (throws)
RPC Conversion
Method Description toRpc(tx)Convert to JSON-RPC format fromRpc(rpc)Parse from JSON-RPC format
Utilities
Method Description getChainId(tx)Extract chain ID getGasPrice(tx, baseFee?)Get effective gas price hasAccessList(tx)Check for access list getAccessList(tx)Get access list format(tx)Format for display
Transaction Types
Type Name Description 0x00Legacy Original format with fixed gas price 0x01EIP-2930 Access list transactions for gas optimization 0x02EIP-1559 Dynamic fee market with base fee and priority fee 0x03EIP-4844 Blob transactions for L2 data availability 0x04EIP-7702 EOA delegation to smart contracts
Type Definitions
// Transaction type enum
enum Type {
Legacy = 0x00 ,
EIP2930 = 0x01 ,
EIP1559 = 0x02 ,
EIP4844 = 0x03 ,
EIP7702 = 0x04 ,
}
// Legacy transaction (Type 0)
type Legacy = {
type : Type . Legacy
nonce : bigint
gasPrice : bigint
gasLimit : bigint
to : AddressType | null
value : bigint
data : Uint8Array
v : bigint
r : Uint8Array
s : Uint8Array
}
// EIP-2930 transaction (Type 1)
type EIP2930 = {
type : Type . EIP2930
chainId : bigint
nonce : bigint
gasPrice : bigint
gasLimit : bigint
to : AddressType | null
value : bigint
data : Uint8Array
accessList : AccessList
yParity : number
r : Uint8Array
s : Uint8Array
}
// EIP-1559 transaction (Type 2)
type EIP1559 = {
type : Type . EIP1559
chainId : bigint
nonce : bigint
maxPriorityFeePerGas : bigint
maxFeePerGas : bigint
gasLimit : bigint
to : AddressType | null
value : bigint
data : Uint8Array
accessList : AccessList
yParity : number
r : Uint8Array
s : Uint8Array
}
// EIP-4844 transaction (Type 3)
type EIP4844 = {
type : Type . EIP4844
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
blobVersionedHashes : readonly VersionedHash []
yParity : number
r : Uint8Array
s : Uint8Array
}
// EIP-7702 transaction (Type 4)
type EIP7702 = {
type : Type . EIP7702
chainId : bigint
nonce : bigint
maxPriorityFeePerGas : bigint
maxFeePerGas : bigint
gasLimit : bigint
to : AddressType | null
value : bigint
data : Uint8Array
accessList : AccessList
authorizationList : AuthorizationList
yParity : number
r : Uint8Array
s : Uint8Array
}
// Union type for all transactions
type Any = Legacy | EIP2930 | EIP1559 | EIP4844 | EIP7702
Source: types.ts
API Methods
Serialization
serialize - RLP encode transaction to bytes
deserialize - RLP decode transaction from bytes
detectType - Detect transaction type from serialized bytes
toRpc - Convert transaction to JSON-RPC format
fromRpc - Parse transaction from JSON-RPC format
Hashing
Signatures
Gas Pricing
Access Lists
Utilities
getChainId - Extract chain ID from transaction
format - Format transaction for display
Usage Patterns
Common patterns for working with transactions:
View usage patterns →
Tree-Shaking
Import only what you need:
// Namespace import (all methods)
import * as Transaction from 'tevm/Transaction' ;
// Granular imports (tree-shakeable)
import { serialize } from 'tevm/Transaction/serialize' ;
import { hash } from 'tevm/Transaction/hash' ;
import { getSender } from 'tevm/Transaction/getSender' ;
Specification