Try it Live
Run ABI examples in the interactive playground
Usage Examples
Format Function
Format Event
Format Error
See Also
- formatWithArgs - Format with argument values
- getSignature - Get canonical signature (no names)
Format ABI item to human-readable signature string
import * as Abi from 'tevm/Abi'
const fn = {
type: "function",
name: "balanceOf",
inputs: [{ type: "address", name: "owner" }],
outputs: [{ type: "uint256", name: "balance" }]
}
console.log(Abi.format(fn))
// "function balanceOf(address owner) returns (uint256 balance)"
import * as Abi from 'tevm/Abi'
const event = {
type: "event",
name: "Transfer",
inputs: [
{ type: "address", name: "from", indexed: true },
{ type: "address", name: "to", indexed: true },
{ type: "uint256", name: "value" }
]
}
console.log(Abi.format(event))
// "event Transfer(address indexed from, address indexed to, uint256 value)"
import * as Abi from 'tevm/Abi'
const error = {
type: "error",
name: "InsufficientBalance",
inputs: [
{ type: "uint256", name: "balance" },
{ type: "uint256", name: "required" }
]
}
console.log(Abi.format(error))
// "error InsufficientBalance(uint256 balance, uint256 required)"
Was this page helpful?