Skip to content

AbiItem.getSignatureHash

Computes the signature hash for an AbiItem.AbiItem.

Useful for computing Event Topic values.

Imports

Named
import { AbiItem } from 'ox'

Examples

import { AbiItem } from 'ox'
 
const hash = AbiItem.getSignatureHash('event Transfer(address indexed from, address indexed to, uint256 amount)')
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
import { Abi, AbiItem } from 'ox'
 
const erc20Abi = Abi.from([...])
 
const hash = AbiItem.getSignatureHash(erc20Abi, 'Transfer')
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
import { AbiItem } from 'ox'
 
const hash = AbiItem.getSignatureHash({
  name: 'Transfer',
  type: 'event',
  inputs: [
    { name: 'from', type: 'address', indexed: true },
    { name: 'to', type: 'address', indexed: true },
    { name: 'amount', type: 'uint256', indexed: false },
  ],
})
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'

Definition

function getSignatureHash<abi, name>(
  abi: abi | Abi.Abi | readonly unknown[],
  name: name,
): Hex.Hex

Source: src/core/AbiItem.ts

Parameters

abi

  • Type: abi | Abi.Abi | readonly unknown[]

name

  • Type: name

Return Type

The Hash.keccak256 hash of the ABI item's signature.

Hex.Hex