init

init is a factory function that creates a read-only or writable client. By providing a signer, additional write APIs that require signing (like setRecord and transfer) become available. By default, a read-only client is returned and no write APIs are available.

HyperBeam Support

When a hyperbeamUrl is provided, the ANT will automatically attempt to fetch state from HyperBeam nodes for improved performance. This feature is particularly useful for newer ANTs that publish patch messages of their state on changes, allowing for cached state retrieval and reduced computational unit usage.

Parameters

ParameterTypeDescriptionOptional
processIdStringThe AO process ID of the ANT to connect to.false
processAOProcess

A pre-configured AOProcess instance used to initialize the ANT class

true
signerContractSigner

An optional signer instance, used to enable write operations on the blockchain

true
hyperbeamUrlstring

Optional HyperBeam URL for cached state retrieval. When provided, the ANT will attempt to fetch state from HyperBeam nodes for improved performance.

true

Examples

init

const { ANT } = require("@ar.io/sdk")

const ant = ANT.init(
    {
        processId: "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM"
    }
)

Was this page helpful?