Overview
Item.isEvent checks whether an ABI item is an event and narrows the type in TypeScript.
Type guard for event ABI items
Item.isEvent checks whether an ABI item is an event and narrows the type in TypeScript.
import { Abi } from '@tevm/voltaire/Abi';
const item = {
type: 'event',
name: 'Transfer',
inputs: [
{ type: 'address', name: 'from', indexed: true },
{ type: 'address', name: 'to', indexed: true },
{ type: 'uint256', name: 'value' }
]
} as const;
if (Abi.Item.isEvent(item)) {
const topic0 = Abi.Event.getSelector(item);
}
Was this page helpful?
Suggestions