Skip to content

getEventSignature

getEventSignature(abi, eventName): string

Defined in: utils/event-topic.ts:44

Builds an event signature from a JSONABI array and event name, then returns its keccak256 hash (topic0).

Parameters

abi

JSONABI

the contract ABI as a JSONABI array

eventName

string

the name of the event to look up

Returns

string

the keccak256 hash of the event signature as a hex string

Example

const abi = [
{
type: 'event',
name: 'Transfer',
inputs: [
{ name: 'from', type: 'address', indexed: true },
{ name: 'to', type: 'address', indexed: true },
{ name: 'value', type: 'uint256', indexed: false },
],
},
];
getEventSignature(abi, 'Transfer');
// '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'