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.
Overview
Abi.getItem finds the first matching ABI item by name, optionally filtered by item type. It returns undefined when no match is found.
Quick Start
import { Abi } from '@tevm/voltaire/Abi';
const abi = Abi([
{
type: 'function',
name: 'transfer',
inputs: [
{ type: 'address', name: 'to' },
{ type: 'uint256', name: 'amount' }
],
outputs: [{ type: 'bool' }]
},
{
type: 'event',
name: 'Transfer',
inputs: [
{ type: 'address', name: 'from', indexed: true },
{ type: 'address', name: 'to', indexed: true },
{ type: 'uint256', name: 'value' }
]
}
] as const);
const transferFn = Abi.getItem(abi, 'transfer', 'function');
const transferEvent = Abi.getItem(abi, 'Transfer', 'event');
Using the Abi Instance
const transferFn = abi.getItem('transfer', 'function');
Overloaded Functions
If your ABI has overloads, match by signature:
const signature = 'foo(address,uint256)';
const fn = abi.find(
(item) =>
item.type === 'function' &&
Abi.Function.getSignature(item) === signature
);
See Also