Skip to content

toEventSignature

Returns the signature for a given event definition.

Install

import { toEventSignature } from 'viem'

Usage

import { toEventSignature } from 'viem'
 
// from event definition
const signature_1 = toEventSignature('event Transfer(address indexed from, address indexed to, uint256 amount)')
Output: Transfer(address,address,uint256)
// from an `AbiEvent` on your contract ABI const signature_2 = toEventSignature({ name: 'Transfer', type: 'event', inputs: [ { name: 'address', type: 'address', indexed: true }, { name: 'address', type: 'address', indexed: true }, { name: 'uint256', type: 'uint256', indexed: false }, ], })
Output: Transfer(address,address,uint256)

Returns

string

The signature as a string value.

Parameters

definition

  • Type: string | AbiEvent

The event definition to generate a signature for.