toEventHash
Returns the hash (of the event signature) for a given event definition.
Install
import { toEventHash } from 'viem'
Usage
import { function toEventHash(fn: string | AbiFunction | AbiEvent): `0x${string}`Returns the hash (of the function/event signature) for a given event or function definition.
toEventHash } from 'viem'
const const hash_1: `0x${string}`hash_1 = function toEventHash(fn: string | AbiFunction | AbiEvent): `0x${string}`Returns the hash (of the function/event signature) for a given event or function definition.
toEventHash('event Transfer(address,address,uint256)')Output: 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
const const hash_2: `0x${string}`hash_2 = function toEventHash(fn: string | AbiFunction | AbiEvent): `0x${string}`Returns the hash (of the function/event signature) for a given event or function definition.
toEventHash({
name: stringname: 'Transfer',
type: "event"type: 'event',
inputs: readonly AbiEventParameter[]inputs: [
{ name: stringname: 'from', type: "address"type: 'address', indexed: trueindexed: true },
{ name: stringname: 'to', type: "address"type: 'address', indexed: trueindexed: true },
{ name: stringname: 'amount', type: "uint256"type: 'uint256', indexed: falseindexed: false },
],
})Output: 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
Returns
The hash of the event signature.
Parameters
event
- Type:
string
|AbiEvent
The event to generate a hash for.