Skip to main content

Aleo Network Client

Overview

Client library that encapsulates REST calls to publicly exposed endpoints of Aleo nodes. The methods provided in this allow users to query public information from the Aleo blockchain and submit transactions to the network.

Kind: global class

Constructor

AleoNetworkClient

Create a new AleoNetworkClient instance to interact with the Aleo network.

new AleoNetworkClient(host, options)
ParamTypeDescription
hoststringThe URL of the Aleo node to connect to
optionsAleoNetworkClientOptionsOptional configuration options

Interface

interface AleoNetworkClientOptions {
headers?: Record<string, string>;
}
PropertyTypeDescription
headersRecord<string, string>Optional headers to include in all requests

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

// Connection to a local node
const localConnection = new AleoNetworkClient("http://localhost:3030");

// Connection to a public beacon node
const publicConnection = new AleoNetworkClient("https://api.explorer.provable.com/v1");

// Connection with custom headers
const customConnection = new AleoNetworkClient("https://api.explorer.provable.com/v1", {
headers: { "Authorization": "Bearer token" }
});

Methods

setHost

Set a new host for the networkClient

networkClient.setHost(host)
ParamTypeDescription
hoststringThe URL of the Aleo node to connect to

Example

// New connection to a public beacon node
let public_connection = AleoNetworkClient.setHost("https://api.explorer.provable.com/v1");


setAccount

Set an account to use in networkClient calls

networkClient.setAccount(account)
ParamTypeDescription
accountAccountThe account to use for networkClient calls

Example

let account = new Account();
networkClient.setAccount(account);


getAccount

Return the Aleo account used in the networkClient

networkClient.getAccount()Account | undefined
ParamTypeDescription
returnAccount | undefinedThe account if set, otherwise undefined

Example

let account = networkClient.getAccount();

setVerboseErrors

Set verbose errors to true or false for the AleoNetworkClient. When set to true, if submitTransaction fails, the failure responses will report descriptive information as to why the transaction failed.

networkClient.setVerboseErrors(verboseErrors)
ParamTypeDescription
verboseErrorsbooleanSet verbose error mode to true or false

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

// Create a networkClient
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");

// Set verbose mode to true
networkClient.setVerboseErrors(true);

setHeader

Set a header in the AleoNetworkClient's header map

networkClient.setHeader(headerName, value)
ParamTypeDescription
headerNamestringThe name of the header to set
valuestringThe header value

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

// Create a networkClient
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");

// Set the value of the `Accept-Language` header to `en-US`
networkClient.setHeader('Accept-Language', 'en-US');

removeHeader

Remove a header from the AleoNetworkClient's header map

networkClient.removeHeader(headerName)
ParamTypeDescription
headerNamestringThe name of the header to remove


fetchData

Fetches data from the Aleo network and returns it as a JSON object.

networkClient.fetchData(url)Promise.<Type>
ParamTypeDescription
urlstringThe URL to fetch data from
returnPromise.<Type>A JSON object parsed from the response

fetchRaw

Fetches data from the Aleo network and returns it as an unparsed string. This method should be used when it is desired to reconstitute data returned from the network into a WASM object.

networkClient.fetchRaw(url)Promise.<string>
ParamTypeDescription
urlstringThe URL to fetch data from
returnPromise.<string>The raw response as an unparsed string

findRecords

Attempt to find records in the Aleo blockchain.

networkClient.findRecords(startHeight, endHeight, unspent, programs, amounts, maxMicrocredits, nonces, privateKey)Promise.<Array.<RecordPlaintext>>
ParamTypeDescription
startHeightnumberThe height at which to start searching for unspent records
endHeightnumberThe height at which to stop searching for unspent records
unspentbooleanWhether to search for unspent records only
programsArray.<string>The program(s) to search for unspent records in
amountsArray.<number>The amounts (in microcredits) to search for (eg. [100, 200, 3000])
maxMicrocreditsnumberThe maximum number of microcredits to search for
noncesArray.<string>The nonces of already found records to exclude from the search
privateKeystringAn optional private key to use to find unspent records.
returnPromise.<Array.<RecordPlaintext>>Array of decrypted record plaintexts

Example

// Find specific amounts
const startHeight = 500000;
const amounts = [600000, 1000000];
const records = await networkClient.findRecords(startHeight, undefined, true, ["credits.aleo"], amounts);

// Find specific amounts with a maximum number of cumulative microcredits
const maxMicrocredits = 100000;
const records = await networkClient.findRecords(startHeight, undefined, true, ["credits.aleo"], undefined, maxMicrocredits);

findUnspentRecords

Attempts to find unspent records in the Aleo blockchain.

networkClient.findUnspentRecords(startHeight, endHeight, programs, amounts, maxMicrocredits, nonces, privateKey)Promise.<Array.<RecordPlaintext>>
ParamTypeDescription
startHeightnumberThe height at which to start searching for unspent records
endHeightnumberThe height at which to stop searching for unspent records
programsArray.<string>The program(s) to search for unspent records in
amountsArray.<number>The amounts (in microcredits) to search for (eg. [100, 200, 3000])
maxMicrocreditsnumberThe maximum number of microcredits to search for
noncesArray.<string>The nonces of already found records to exclude from the search
privateKeystringAn optional private key to use to find unspent records.
returnPromise.<Array.<RecordPlaintext>>Array of decrypted unspent record plaintexts

Example

// Find specific amounts
const startHeight = 500000;
const endHeight = 550000;
const amounts = [600000, 1000000];
const records = await networkClient.findUnspentRecords(startHeight, endHeight, ["credits.aleo"], amounts);

// Find specific amounts with a maximum number of cumulative microcredits
const maxMicrocredits = 100000;
const records = await networkClient.findUnspentRecords(startHeight, undefined, ["credits.aleo"], undefined, maxMicrocredits);

getBlock

Returns the contents of the block at the specified block height.

networkClient.getBlock(height)Promise.<BlockJSON>
ParamTypeDescription
heightnumberThe block height to fetch
returnPromise.<BlockJSON>A JSON representation of the block

Example

let block = await networkClient.getBlock(1234);

getBlockByHash

Returns the contents of the block with the specified hash.

networkClient.getBlockByHash(blockHash)Promise.<BlockJSON>
ParamTypeDescription
blockHashstringThe hash of the block to fetch
returnPromise.<BlockJSON>A javascript object representation of the block matching the hash

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const block = await networkClient.getBlockByHash("ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9");

getBlockRange

Returns a range of blocks between the specified block heights. A maximum of 50 blocks can be fetched at a time.

networkClient.getBlockRange(start, end)Promise.<Array.<BlockJSON>>
ParamTypeDescription
startnumberThe starting block height
endnumberThe ending block height
returnPromise.<Array.<BlockJSON>>Array of blocks in the specified range

Example

let blockRange = await networkClient.getBlockRange(2050, 2100);

getProgram

Returns the source code of a program given a program ID.

networkClient.getProgram(programId, edition)Promise.<string>
ParamTypeDescription
programIdstringThe program ID of a program deployed to the Aleo Network
editionnumber | undefinedOptional edition of the program to fetch. When undefined, fetches the latest version.
returnPromise.<string>Source code of the program

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const program = await networkClient.getProgram("hello_hello.aleo");
const expectedSource = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n"
assert.equal(program, expectedSource);

getLatestProgramEdition

Returns the current program edition deployed on the Aleo network.

networkClient.getLatestProgramEdition(programId)Promise.<number>
ParamTypeDescription
programIdstringThe program ID of a program deployed to the Aleo Network
returnPromise.<number>The edition of the program

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const programEdition = await networkClient.getLatestProgramEdition("hello_hello.aleo");
assert.equal(programEdition, 1);

getProgramObject

Returns a program object from a program ID or program source code.

networkClient.getProgramObject(inputProgram, edition)Promise.<Program>
ParamTypeDescription
inputProgramstringThe program ID or program source code of a program deployed to the Aleo Network
editionnumber | undefinedOptional edition of the program to fetch. When undefined, fetches the latest version.
returnPromise.<Program>Source code of the program

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const programID = "hello_hello.aleo";
const programSource = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n"

// Get program object from program ID or program source code
const programObjectFromID = await networkClient.getProgramObject(programID);
const programObjectFromSource = await networkClient.getProgramObject(programSource);

// Both program objects should be equal
assert(programObjectFromID.to_string() === programObjectFromSource.to_string());

getProgramImports

Returns an object containing the source code of a program and the source code of all programs it imports

networkClient.getProgramImports(inputProgram)Promise.<ProgramImports>
ParamTypeDescription
inputProgramProgramThe program ID or program source code of a program deployed to the Aleo Network
returnPromise.<ProgramImports>

Example

let program = await networkClient.getProgramImports("double_test.aleo");
const double_test_source = "import multiply_test.aleo;\n\nprogram double_test.aleo;\n\nfunction double_it:\n input r0 as u32.private;\n call multiply_test.aleo/multiply 2u32 r0 into r1;\n output r1 as u32.private;\n"
const double_test = Program.fromString(double_test_source);
const expectedImports = {
"multiply_test.aleo": "program multiply_test.aleo;\n\nfunction multiply:\n input r0 as u32.public;\n input r1 as u32.private;\n mul r0 r1 into r2;\n output r2 as u32.private;\n"
}

// Imports can be fetched using the program ID, source code, or program object
let programImports = await networkClient.getProgramImports("double_test.aleo");
assert.deepStrictEqual(programImports, expectedImports);

// Using the program source code
programImports = await networkClient.getProgramImports(double_test_source);
assert.deepStrictEqual(programImports, expectedImports);

// Using the program object
programImports = await networkClient.getProgramImports(double_test);
assert.deepStrictEqual(programImports, expectedImports);

getProgramImportNames

Get a list of the program names that a program imports.

networkClient.getProgramImportNames(inputProgram)Array.<string>
ParamTypeDescription
inputProgramProgramThe program id or program source code to get the imports of
returnArray.<string>Array of program names that the input program imports

Example

let mappings = networkClient.getProgramImportNames("double_test.aleo");
const expectedImportsNames = ["multiply_test.aleo"];
assert.deepStrictEqual(programImportsNames, expectedImportsNames);

getDeploymentTransactionIDForProgram

Returns the deployment transaction id associated with the specified program.

networkClient.getDeploymentTransactionIDForProgram(program)TransactionJSON
ParamTypeDescription
programProgramThe program ID to look up
returnPromise.<string>The transaction ID of the deployment

Example

let program = networkClient.getDeploymentTransactionIDForProgram("foo.aleo");

getDeploymentTransactionForProgram

Returns the deployment transaction associated with a specified program.

networkClient.getDeploymentTransactionForProgram(program)TransactionJSON
ParamTypeDescription
programProgramThe program ID to look up
returnPromise.<TransactionJSON>The deployment transaction JSON

Example

let program = networkClient.getDeploymentTransactionForProgram("foo.aleo");

getDeploymentTransactionObjectForProgram

Returns the deployment transaction associated with a specified program as a wasm object.

networkClient.getDeploymentTransactionObjectForProgram(program)TransactionJSON
ParamTypeDescription
programProgramThe program ID to look up
returnPromise.<Transaction>The deployment transaction as a WASM object

getProgramMappingNames

Returns the names of the mappings of a program.

networkClient.getProgramMappingNames(programId)Promise.<Array.<string>>
ParamTypeDescription
programIdstringThe program ID to get the mappings of (e.g. "credits.aleo")
returnPromise.<Array.<string>>Array of mapping names in the program

Example

let mappings = await networkClient.getProgramMappingNames("credits.aleo");
const expectedMappings = [
"committee",
"delegated",
"metadata",
"bonded",
"unbonding",
"account",
"withdraw"
];
assert.deepStrictEqual(mappings, expectedMappings);

getProgramMappingValue

Returns the value of a program's mapping for a specific key.

networkClient.getProgramMappingValue(programId, mappingName, key)Promise.<string>
ParamTypeDescription
programIdstringThe program ID to get the mapping value of (e.g. "credits.aleo")
mappingNamestringThe name of the mapping to get the value of (e.g. "account")
keystringThe key of the mapping to get the value of (e.g. "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
returnPromise.<string>The value at the specified key as a string

Example

// Get public balance of an account
let mappingValue = await networkClient.getProgramMappingValue("credits.aleo", "account", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
const expectedValue = "0u64";
assert.equal(mappingValue, expectedValue);

getProgramMappingPlaintext

Returns the value of a mapping as a wasm Plaintext object. Returning an object in this format allows it to be converted to a Js type and for its internal members to be inspected if it's a struct or array.

networkClient.getProgramMappingPlaintext(programId, mappingName, key)Promise.<string>
ParamTypeDescription
programIdstringThe program ID to get the mapping value of (e.g. "credits.aleo")
mappingNamestringThe name of the mapping to get the value of (e.g. "account")
keystringThe key of the mapping to get the value of (e.g. "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
returnPromise.<Plaintext>The value as a Plaintext WASM object

Example

// Get the bond state as an account.
const unbondedState = await networkClient.getProgramMappingPlaintext("credits.aleo", "bonded", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");

// Get the two members of the object individually.
const validator = unbondedState.getMember("validator");
const microcredits = unbondedState.getMember("microcredits");

// Ensure the expected values are correct.
assert.equal(validator, "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd");
assert.equal(microcredits, BigInt("9007199254740991"));

// Get a JS object representation of the unbonded state.
const unbondedStateObject = unbondedState.toObject();

const expectedState = {
validator: "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd",
microcredits: BigInt("9007199254740991")
};
assert.deepEqual(unbondedStateObject, expectedState);

getPublicBalance

Returns the public balance of an address from the account mapping in credits.aleo

networkClient.getPublicBalance(address)Promise.<number>
ParamTypeDescription
addressAddress | stringA string or wasm object representing an address
returnPromise.<number>The public balance of the address in microcredits

Example

import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";

// Create a network client.
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");

// Get the balance of an account from either an address object or address string.
const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
const publicBalance = await networkClient.getPublicBalance(account.address());
const publicBalanceFromString = await networkClient.getPublicBalance(account.address().to_string());
assert(publicBalance === publicBalanceFromString);

getLatestBlock

Returns the contents of the latest block.

networkClient.getLatestBlock()Promise.<BlockJSON>
ParamTypeDescription
returnPromise.<BlockJSON>The latest block as JSON

Example

let latestHeight = await networkClient.getLatestBlock();

getLatestHeight

Returns the latest block height.

networkClient.getLatestHeight()Promise.<number>
ParamTypeDescription
returnPromise.<number>The latest block height

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const latestHeight = await networkClient.getLatestHeight();

getLatestBlockHash

Returns the latest block hash.

networkClient.getLatestBlockHash()Promise.<string>
ParamTypeDescription
returnPromise.<string>The latest block hash

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const latestHash = await networkClient.getLatestBlockHash();

getLatestCommittee

Returns the latest committee.

networkClient.getLatestCommittee()Promise.<object>
ParamTypeDescription
returnPromise.<object>The current validator committee

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const latestCommittee = await networkClient.getLatestCommittee();

getCommitteeByBlockHeight

Returns the committee at the specified block height.

networkClient.getCommitteeByBlockHeight(blockHeight)Promise.<object>
ParamTypeDescription
blockHeightnumberThe height of the block to fetch the committee for
returnPromise.<object>A javascript object containing the committee

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const committee = await networkClient.getCommitteeByBlockHeight(1234);

getStateRoot

Returns the latest state/merkle root of the Aleo blockchain.

networkClient.getStateRoot()Promise.<string>
ParamTypeDescription
returnPromise.<string>The current state/merkle root

Example

let stateRoot = await networkClient.getStateRoot();

getTransaction

Returns a transaction by its unique identifier.

networkClient.getTransaction(id)Promise.<TransactionJSON>
ParamTypeDescription
idstringThe transaction ID to look up
returnPromise.<TransactionJSON>The transaction as JSON

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const transaction = await networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");

getConfirmedTransaction

Returns a confirmed transaction by its unique identifier.

networkClient.getConfirmedTransaction(transactionId)Promise.<ConfirmedTransactionJSON>
ParamTypeDescription
transactionIdstringThe transaction ID to fetch
returnPromise.<ConfirmedTransactionJSON>A json object containing the confirmed transaction

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const transaction = await networkClient.getConfirmedTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
assert.equal(transaction.status, "accepted");

getTransactionObject

Returns a transaction as a wasm object. Getting a transaction of this type will allow the ability for the inputs, outputs, and records to be searched for and displayed.

networkClient.getTransactionObject(transactionId)Promise.<Transaction>
ParamTypeDescription
transactionIdstringThe transaction ID to look up
returnPromise.<Transaction>The transaction as a WASM object

Example

const transactionObject = await networkClient.getTransactionObject("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
// Get the transaction inputs as a JS array.
const transactionOutputs = transactionObject.inputs(true);

// Get the transaction outputs as a JS object.
const transactionInputs = transactionObject.outputs(true);

// Get any records generated in transitions in the transaction as a JS object.
const records = transactionObject.records();

// Get the transaction type.
const transactionType = transactionObject.transactionType();
assert.equal(transactionType, "Execute");

// Get a JS representation of all inputs, outputs, and transaction metadata.
const transactionSummary = transactionObject.summary();

getTransactions

Returns the transactions present at the specified block height.

networkClient.getTransactions(height)Promise.<Array.<ConfirmedTransactionJSON>>
ParamTypeDescription
heightnumberThe block height to fetch transactions for
returnPromise.<Array.<ConfirmedTransactionJSON>>Array of confirmed transactions

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const transactions = await networkClient.getTransactions(654);

getTransactionsByBlockHash

Returns the confirmed transactions present in the block with the specified block hash.

networkClient.getTransactionsByBlockHash(blockHash)Promise.<Array.<ConfirmedTransactionJSON>>
ParamTypeDescription
blockHashstringThe block hash to fetch the confirmed transactions at
returnPromise.<Array.<ConfirmedTransactionJSON>>An array of confirmed transactions (in JSON format) for the block hash

Example

import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";

const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const transactions = await networkClient.getTransactionsByBlockHash("ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9");

getTransactionsInMempool

Returns the transactions in the memory pool. This method requires access to a validator's REST API.

networkClient.getTransactionsInMempool()Promise.<Array.<TransactionJSON>>
ParamTypeDescription
returnPromise.<Array.<TransactionJSON>>Array of transactions currently in the mempool

Example

let transactions = await networkClient.getTransactionsInMempool();

getTransitionId

Returns the transition ID of the transition corresponding to the ID of the input or output.

networkClient.getTransitionId(inputOrOutputID)Promise.<string>
ParamTypeDescription
inputOrOutputIDstringID of the input or output.
returnPromise.<string>The transition ID containing the input or output

Example

let transition = await networkClient.getTransitionId("2429232855236830926144356377868449890830704336664550203176918782554219952323field");

submitTransaction

Submit an execute or deployment transaction to the Aleo network.

networkClient.submitTransaction(transaction) ⇒ string
ParamTypeDescription
transactionTransactionThe transaction to submit to the network
returnPromise.<string>The transaction ID of the submitted transaction

submitSolution

Submit a solution to the Aleo network.

networkClient.submitSolution(solution)Promise.<string>
ParamTypeDescription
solutionstringThe string representation of the solution desired to be submitted to the network.
returnPromise.<string>The solution id of the submitted solution or the resulting error

submitProvingRequest

Submit a ProvingRequest to a remote proving service for delegated proving. If the broadcast flag of the ProvingRequest is set to true, the remote service will attempt to broadcast the result Transaction on behalf of the requestor.

networkClient.submitProvingRequest(options)Promise.<ProvingResponse>
ParamTypeDescription
optionsDelegatedProvingParamsThe optional parameters required to submit a proving request
returnPromise.<ProvingResponse>The ProvingResponse containing the transaction result and the result of the broadcast if the broadcast flag was set to true

DelegatedProvingParams Interface

PropertyTypeDescription
provingRequestProvingRequest | stringThe proving request being submitted to the network
urlstringOptional URL of the delegated proving service
apiKeystringOptional API key used for generating a JWT
consumerIdstringOptional consumer ID associated with the API key
jwtDataJWTDataOptional JWT token used for authenticating with the proving service

waitForTransactionConfirmation

Await a submitted transaction to be confirmed or rejected on the Aleo network.

networkClient.waitForTransactionConfirmation(transactionId, checkInterval, timeout)Promise.<ConfirmedTransactionJSON>
ParamTypeDescription
transactionIdstringThe transaction ID to wait for confirmation
checkIntervalnumberThe interval in milliseconds to check for confirmation (default: 2000)
timeoutnumberThe maximum time in milliseconds to wait for confirmation (default: 45000)
returnPromise.<ConfirmedTransactionJSON>The confirmed transaction object that returns if the transaction is confirmed

Example

import { AleoNetworkClient, Account, ProgramManager } from "@provablehq/sdk/mainnet.js";

// Create a network client and program manager.
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const programManager = new ProgramManager("https://api.explorer.provable.com/v1");

// Set the account for the program manager.
programManager.setAccount(Account.fromCiphertext(process.env.ciphertext, process.env.password));

// Build a transfer transaction.
const tx = await programManager.buildTransferPublicTransaction(100, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", 0);

// Submit the transaction to the network.
const transactionId = await networkClient.submitTransaction(tx);

// Wait for the transaction to be confirmed.
const transaction = await networkClient.waitForTransactionConfirmation(transactionId);