@tevm/tx
Tevm's transaction facade backed by @evmts/zevm/tx. Exports typed Ethereum transaction constructors, helpers, type guards, and Tevm's impersonated transaction helper.
Full API: packages/tx/docs.
Installation
npm install @tevm/txAPI Reference
Transaction Types
- LegacyTransaction
- AccessListEIP2930Transaction
- FeeMarketEIP1559Transaction
- BlobEIP4844Transaction
EOACodeEIP7702Transaction- EIP-7702 EOA code transactions.- ImpersonatedTx - Tevm-specific tx that executes as an address without a private key.
Helpers
TransactionFactory- alias for ZEVM'screateTx.createTxFromRLP- decode a serialized transaction.createTxFromBlockBodyData- create from block body data.createImpersonatedTx- unsigned EIP-1559-shaped tx that executes asimpersonatedAddress.createEOACodeEIP7702Tx,createEOACodeEIP7702TxFromBytesArray,createEOACodeEIP7702TxFromRLP.- Type guards:
isLegacyTx,isAccessListEIP2930Tx,isFeeMarketEIP1559Tx,isBlobEIP4844Tx,isEOACodeEIP7702Tx.
Creating Transactions
import {
TransactionFactory,
createImpersonatedTx,
createTxFromRLP,
isBlobEIP4844Tx,
isEOACodeEIP7702Tx,
} from '@tevm/tx'
import { createAddress } from '@tevm/address'
const tx = TransactionFactory({
nonce: 0n,
gasLimit: 21000n,
maxFeePerGas: 20_000_000_000n,
maxPriorityFeePerGas: 2_000_000_000n,
to: createAddress('0x1234567890123456789012345678901234567890'),
value: 1_000_000_000_000_000_000n,
})
const decoded = createTxFromRLP(tx.serialize())
if (isBlobEIP4844Tx(decoded) || isEOACodeEIP7702Tx(decoded)) {
// typed transaction fields
}Impersonated Transactions
Lets the VM execute as an address without a signature. For app-level impersonation, prefer JSON-RPC or MemoryClient helpers (anvil_impersonateAccount, tevm_impersonateAccount, setImpersonatedAccount).
import { createImpersonatedTx } from '@tevm/tx'
import { createAddress } from '@tevm/address'
const tx = createImpersonatedTx({
impersonatedAddress: createAddress('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'),
to: createAddress('0x70997970c51812dc3a010c7d01b50e0d17dc79c8'),
value: 1_000_000_000_000_000_000n,
gasLimit: 21_000n,
maxFeePerGas: 20_000_000_000n,
maxPriorityFeePerGas: 2_000_000_000n,
nonce: 0n,
})
const vm = await node.getVm()
const result = await vm.runTx({ tx, skipBalance: true, skipNonce: true })Transaction Coverage
Legacy, EIP-2930, EIP-1559, EIP-4844, EIP-7702, and Tevm impersonated transactions.
Common Methods
hash(), getBaseFee(), getDataFee(), getUpfrontCost(), isSigned(), serialize(), toJSON().

