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 ABI examples in the interactive playground
Overview
Abi.format renders ABI items as human-readable strings. It includes parameter names, return types (for functions), and state mutability when relevant.
Quick Start
import { Abi } from '@tevm/voltaire/Abi';
const fn = {
type: 'function',
name: 'balanceOf',
inputs: [{ type: 'address', name: 'owner' }],
outputs: [{ type: 'uint256', name: 'balance' }],
stateMutability: 'view'
} as const;
const formatted = Abi.format(fn);
// "function balanceOf(address owner) returns (uint256) view"
const event = {
type: 'event',
name: 'Transfer',
inputs: [
{ type: 'address', name: 'from', indexed: true },
{ type: 'address', name: 'to', indexed: true },
{ type: 'uint256', name: 'value' }
]
} as const;
const error = {
type: 'error',
name: 'InsufficientBalance',
inputs: [
{ type: 'uint256', name: 'balance' },
{ type: 'uint256', name: 'required' }
]
} as const;
Abi.format(event);
// "event Transfer(address indexed from, address indexed to, uint256 value)"
Abi.format(error);
// "error InsufficientBalance(uint256 balance, uint256 required)"
const abi = Abi([fn, event, error] as const);
const formatted = abi.format();
// ["function ...", "event ...", "error ..."]
See Also