toFunctionSignature
Returns the signature for a given function definition.
Install
import { toFunctionSignature } from 'viem'
Usage
import { toFunctionSignature } from 'viem'
// from function definition
const signature_1 = toFunctionSignature('function ownerOf(uint256 tokenId)')
Output: ownerOf(uint256) // from an `AbiFunction` on your contract ABI
const signature_2 = toFunctionSignature({
name: 'ownerOf',
type: 'function',
inputs: [{ name: 'tokenId', type: 'uint256' }],
outputs: [],
stateMutability: 'view',
})
Output: ownerOf(uint256)
Returns
string
The signature as a string value.
Parameters
definition
- Type:
string | AbiFunction
The function definition to generate a signature for.