Overview
Item.isFunction checks whether an ABI item is a function and narrows the type in TypeScript.
Type guard for function ABI items
Item.isFunction checks whether an ABI item is a function and narrows the type in TypeScript.
import { Abi } from '@tevm/voltaire/Abi';
const item = {
type: 'function',
name: 'balanceOf',
inputs: [{ type: 'address', name: 'owner' }],
outputs: [{ type: 'uint256' }]
} as const;
if (Abi.Item.isFunction(item)) {
const selector = Abi.Function.getSelector(item);
}
Was this page helpful?
Suggestions