Docs

Modules

Complete module reference for eth.zig -- primitives, encoding, crypto, transport, and more.

Complete reference for all eth.zig modules, organized by layer.

Primitives

Core types and encoding utilities.

ModuleKey ExportsDescription
primitivesAddress, Hash, Bytes32, addressToChecksumCore Ethereum types with EIP-55 checksum support
uint256u256, arithmetic ops256-bit unsigned integer type
hexhexToBytesFixed, bytesToHexHex string encoding and decoding
unitsparseEther, parseGwei, formatEtherWei/Gwei/Ether unit conversions

Encoding

RLP and ABI encoding/decoding with comptime support.

ModuleKey ExportsDescription
rlpencode, decodeRecursive Length Prefix encoding
abi_encodeencode, encodePackedABI encoding for function calls and data
abi_decodedecode, decodeOutputABI decoding of return values and calldata
abi_typesAbiType, Function, EventABI type definitions
abi_comptimecomptimeSelector, comptimeTopicCompile-time function selectors and event topics
abi_jsonparseAbiParse Solidity JSON ABI files

Comptime Selectors

const eth = @import("eth");

// Computed at compile time -- zero runtime cost
const transfer_sel = eth.abi_comptime.comptimeSelector("transfer(address,uint256)");
// transfer_sel == [4]u8{ 0xa9, 0x05, 0x9c, 0xbb }

const transfer_topic = eth.abi_comptime.comptimeTopic("Transfer(address,address,uint256)");
// transfer_topic == keccak256("Transfer(address,address,uint256)")

Crypto

Pure Zig cryptographic primitives -- no C dependencies.

ModuleKey ExportsDescription
secp256k1sign, recover, publicKeyECDSA on secp256k1 (RFC 6979, EIP-2 low-S)
signerSignerHigh-level signing with address derivation
signatureSignature, recoverAddressSignature type with v/r/s and recovery
keccakkeccak256Keccak-256 hashing
eip155applyEip155, chainIdEIP-155 replay protection

Transaction Types

All Ethereum transaction formats.

ModuleKey ExportsDescription
transactionTransaction, LegacyTx, Eip1559Tx, Eip4844TxLegacy, EIP-2930, EIP-1559, EIP-4844 transaction types
receiptTransactionReceiptTransaction receipt with logs and status
blockBlock, BlockHeaderBlock and block header types
blobBlob, BlobSidecarEIP-4844 blob transaction support
access_listAccessList, AccessListItemEIP-2930 access list types

Accounts

HD wallet and mnemonic support.

ModuleKey ExportsDescription
mnemonicgenerate, toSeed, validateBIP-39 mnemonic phrase generation and validation
hd_walletderiveEthAccount, HDKeyBIP-32/44 hierarchical deterministic key derivation

HD Wallet Example

const eth = @import("eth");

const words = [_][]const u8{
    "abandon", "abandon", "abandon", "abandon",
    "abandon", "abandon", "abandon", "abandon",
    "abandon", "abandon", "abandon", "about",
};
const seed = try eth.mnemonic.toSeed(&words, "");
const key = try eth.hd_wallet.deriveEthAccount(seed, 0);
const addr = key.toAddress();

Transport

JSON-RPC communication with Ethereum nodes.

ModuleKey ExportsDescription
http_transportHttpTransportHTTP JSON-RPC transport
ws_transportWebSocketTransportWebSocket JSON-RPC transport with TLS
json_rpcRequest, ResponseJSON-RPC 2.0 types
providerProviderHigh-level provider with 24+ JSON-RPC methods
subscriptionSubscriptionWebSocket event subscriptions

Provider Methods

The Provider supports all standard Ethereum JSON-RPC methods:

MethodDescription
getBalanceGet ETH balance
getTransactionCountGet account nonce
getBlockNumberCurrent block number
getBlockGet block by number or hash
getTransactionReceiptGet transaction receipt
callExecute a read-only call
estimateGasEstimate gas for a transaction
sendRawTransactionBroadcast a signed transaction
getLogsQuery event logs
getCodeGet contract bytecode
getStorageAtRead contract storage
getGasPriceCurrent gas price
getMaxPriorityFeePerGasEIP-1559 priority fee
getChainIdChain ID

ENS

Ethereum Name Service resolution.

ModuleKey ExportsDescription
ens_namehashnamehashENS name to namehash conversion
ens_resolverresolveForward resolution (name to address)
ens_reversereverseResolveReverse resolution (address to name)

Client

High-level client abstractions for common operations.

ModuleKey ExportsDescription
walletWalletSigning wallet with sendTransaction, readContract, writeContract
contractContractContract interaction helpers
multicallMulticall3Batch multiple read calls into a single RPC request
eventEvent, decodeLogEvent log decoding and filtering
erc20ERC20, selectorsTyped ERC-20 wrapper with comptime selectors
erc721ERC721Typed ERC-721 wrapper

ERC-20 Example

const eth = @import("eth");

var token = eth.erc20.ERC20.init(allocator, token_addr, &provider);
const balance = try token.balanceOf(holder_addr);
const name = try token.name();
defer allocator.free(name);
const decimals = try token.decimals();

Standards

Ethereum Improvement Proposals.

ModuleKey ExportsDescription
eip712hashTypedData, signTypedDataEIP-712 typed structured data hashing and signing
abi_jsonparseAbi, AbiFunctionParse Solidity JSON ABI into typed structures

Chains

Pre-defined chain configurations.

ModuleKey ExportsDescription
chainsethereum, arbitrum, optimism, base, polygonChain ID, RPC URLs, block explorers