Abi
Utilities & types for working with Application Binary Interfaces (ABIs)
Examples
Below are some examples demonstrating common usages of the Abi module:
Instantiating JSON ABIs
An Abi.Abi can be instantiated from a JSON ABI by using Abi.from:
import { } from 'ox'
const = .([
{
: 'function',
: 'approve',
: 'nonpayable',
: [
{
: 'spender',
: 'address'
},
{
: 'amount',
: 'uint256'
}
],
: [{ : 'bool' }]
}
])
abi
Instantiating Human Readable ABIs
An Abi.Abi can be instantiated from a human-readable ABI by using Abi.from:
import { } from 'ox'
const = .([
'function approve(address spender, uint256 amount) returns (bool)'
])
abi
Formatting ABIs
An Abi.Abi can be formatted into a human-readable ABI by using Abi.format:
const = .()
formatted
Functions
| Name | Description |
|---|---|
Abi.format | Formats an Abi.Abi into a Human Readable ABI. |
Abi.from | Parses an arbitrary JSON ABI or Human Readable ABI into a typed Abi.Abi. |
Errors
| Name | Description |
|---|---|
Abi.CircularReferenceError | |
Abi.InvalidSignatureError | |
Abi.InvalidStructSignatureError | |
Abi.UnknownSignatureError |
Types
| Name | Description |
|---|---|
Abi.Abi | Root type for an ABI. |

