Skip to content
LogoLogo

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' }]
  }
])
 
abiArrow

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)'
])
 
abiArrow

Formatting ABIs

An Abi.Abi can be formatted into a human-readable ABI by using Abi.format:

const  = .()
 
formattedArrow

Functions

NameDescription
Abi.formatFormats an Abi.Abi into a Human Readable ABI.
Abi.fromParses an arbitrary JSON ABI or Human Readable ABI into a typed Abi.Abi.

Errors

NameDescription
Abi.CircularReferenceError
Abi.InvalidSignatureError
Abi.InvalidStructSignatureError
Abi.UnknownSignatureError

Types

NameDescription
Abi.AbiRoot type for an ABI.