Skip to content
LogoLogo

toFunctionHash

Returns the hash (of the function signature) for a given function definition.

Install

import { toFunctionHash } from 'viem'

Usage

import {  } from 'viem'
 
const  = ('function ownerOf(uint256)')
Output: 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
// or from an `AbiEvent` on your contract ABI const = ({ : 'ownerOf', : 'function', : [{ : 'tokenId', : 'uint256' }], : [], : 'view', })
Output: 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

Returns

Hex

The hash of the function signature.

Parameters

function

The function to generate a hash for.