Skip to content

AlgorandClient

Defined in: src/algorand-client.ts:19

A client that brokers easy access to Algorand functionality.

get account(): AccountManager

Defined in: src/algorand-client.ts:185

Get or create accounts that can sign transactions.

const accountManager = AlgorandClient.mainNet().account;

AccountManager

The AccountManager instance.


get app(): AppManager

Defined in: src/algorand-client.ts:205

Methods for interacting with apps.

const appManager = AlgorandClient.mainNet().app;

AppManager

The AppManager instance.


get appDeployer(): AppDeployer

Defined in: src/algorand-client.ts:215

Methods for deploying apps and managing app deployment metadata.

const deployer = AlgorandClient.mainNet().appDeployer;

AppDeployer

The AppDeployer instance.


get asset(): AssetManager

Defined in: src/algorand-client.ts:195

Methods for interacting with assets.

const assetManager = AlgorandClient.mainNet().asset;

AssetManager

The AssetManager instance.


get client(): ClientManager

Defined in: src/algorand-client.ts:175

Get clients, including algosdk clients and app clients.

const clientManager = AlgorandClient.mainNet().client;

ClientManager

The ClientManager instance.


get createTransaction(): AlgorandClientTransactionCreator

Defined in: src/algorand-client.ts:293

Methods for creating a transaction.

const payment = await AlgorandClient.mainNet().createTransaction.payment({
sender: "SENDERADDRESS",
receiver: "RECEIVERADDRESS",
amount: algo(1)
})

AlgorandClientTransactionCreator

The AlgorandClientTransactionCreator instance.


get network(): NetworkManager

Defined in: src/algorand-client.ts:235

Methods for interacting with the network. Provides utilities for querying blockchain state and waiting for specific conditions.

// Get last round
const lastRound = await algorand.network.getLastRound()
// Wait for a specific round
await algorand.network.waitUntilRound(1000n)
// LocalNet-specific: block warp
await algorand.network.localNet.blockWarp(100n)

NetworkManager

The NetworkManager instance.


get send(): AlgorandClientTransactionSender

Defined in: src/algorand-client.ts:279

Methods for sending a transaction.

const result = await AlgorandClient.mainNet().send.payment({
sender: "SENDERADDRESS",
receiver: "RECEIVERADDRESS",
amount: algo(1)
})

AlgorandClientTransactionSender

The AlgorandClientTransactionSender instance.

getSuggestedParams(): Promise<{ consensusVersion: string; fee: bigint; firstValid: bigint; flatFee: boolean; genesisHash: Uint8Array; genesisId: string; lastValid: bigint; minFee: bigint; }>

Defined in: src/algorand-client.ts:154

Get suggested params for a transaction (either cached or from algod if the cache is stale or empty)

Promise<{ consensusVersion: string; fee: bigint; firstValid: bigint; flatFee: boolean; genesisHash: Uint8Array; genesisId: string; lastValid: bigint; minFee: bigint; }>

The suggested transaction parameters.

const params = await AlgorandClient.mainNet().getSuggestedParams();

newGroup(composerConfig?): TransactionComposer

Defined in: src/algorand-client.ts:257

Start a new TransactionComposer transaction group

TransactionComposerConfig

TransactionComposer

A new instance of TransactionComposer.

{@includeCode ./algorand-client.spec.ts#example-newGroup}

Full working example


registerErrorTransformer(transformer): void

Defined in: src/algorand-client.ts:243

Register a function that will be used to transform an error caught when simulating or executing composed transaction groups made from newGroup

ErrorTransformer

void


setDefaultSigner(signer): AlgorandClient

Defined in: src/algorand-client.ts:77

Sets the default signer to use if no other signer is specified.

The signer to use, either a TransactionSigner or a AddressWithSigner

AddressWithTransactionSigner | TransactionSigner

AlgorandClient

The AlgorandClient so method calls can be chained

const signer = new SigningAccount(account, account.addr)
const algorand = AlgorandClient.mainNet().setDefaultSigner(signer)

setDefaultValidityWindow(validityWindow): AlgorandClient

Defined in: src/algorand-client.ts:62

Sets the default validity window for transactions.

The number of rounds between the first and last valid rounds

number | bigint

AlgorandClient

The AlgorandClient so method calls can be chained

const algorand = AlgorandClient.mainNet().setDefaultValidityWindow(1000);

setSigner(sender, signer): AlgorandClient

Defined in: src/algorand-client.ts:113

Tracks the given signer against the given sender for later signing.

The sender address to use this signer for

string | Address

TransactionSigner

The signer to sign transactions with for the given sender

AlgorandClient

The AlgorandClient so method calls can be chained

const signer = new SigningAccount(account, account.addr)
const algorand = AlgorandClient.mainNet().setSigner(signer.addr, signer.signer)

setSignerFromAccount(account): AlgorandClient

Defined in: src/algorand-client.ts:97

Tracks the given account (object that encapsulates an address and a signer) for later signing.

The account to register, which can be a AddressWithSigner or a algosdk.Account, algosdk.LogicSigAccount, SigningAccount or MultisigAccount

MultisigAccount | AddressWithTransactionSigner | LogicSigAccount

AlgorandClient

The AlgorandClient so method calls can be chained

const accountManager = AlgorandClient.mainNet()
.setSignerFromAccount(algosdk.generateAccount())
.setSignerFromAccount(new algosdk.LogicSigAccount(program, args))
.setSignerFromAccount(new SigningAccount(account, sender))
.setSignerFromAccount(new MultisigAccount({version: 1, threshold: 1, addrs: ["ADDRESS1...", "ADDRESS2..."]}, [account1, account2]))
.setSignerFromAccount({addr: "SENDERADDRESS", signer: transactionSigner})

setSuggestedParamsCache(suggestedParams, until?): AlgorandClient

Defined in: src/algorand-client.ts:128

Sets a cache value to use for suggested transaction params.

The suggested params to use

string

ConsensusVersion indicates the consensus protocol version as of LastRound.

bigint

Fee is the suggested transaction fee Fee is in units of micro-Algos per byte. Fee may fall to zero but transactions must still have a fee of at least MinTxnFee for the current network protocol.

bigint

boolean

Uint8Array

GenesisHash is the hash of the genesis block.

string

GenesisID is an ID listed in the genesis block.

bigint

bigint

The minimum transaction fee (not per byte) required for the txn to validate for the current network protocol.

Date

A date until which to cache, or if not specified then the timeout is used

AlgorandClient

The AlgorandClient so method calls can be chained

const algorand = AlgorandClient.mainNet().setSuggestedParamsCache(suggestedParams, new Date(+new Date() + 3_600_000))

setSuggestedParamsCacheTimeout(timeout): AlgorandClient

Defined in: src/algorand-client.ts:143

Sets the timeout for caching suggested params.

number

The timeout in milliseconds

AlgorandClient

The AlgorandClient so method calls can be chained

const algorand = AlgorandClient.mainNet().setSuggestedParamsCacheTimeout(10_000)

unregisterErrorTransformer(transformer): void

Defined in: src/algorand-client.ts:247

ErrorTransformer

void


static defaultLocalNet(): AlgorandClient

Defined in: src/algorand-client.ts:306

Creates an AlgorandClient pointing at default LocalNet ports and API token.

AlgorandClient

An instance of the AlgorandClient.

{@includeCode ./algorand-client.spec.ts#example-defaultLocalNet}

Full working example


static fromClients(clients): AlgorandClient

Defined in: src/algorand-client.ts:349

Creates an AlgorandClient pointing to the given client(s).

AlgoSdkClients

The clients to use.

AlgorandClient

An instance of the AlgorandClient.

const algorand = AlgorandClient.fromClients({ algod, indexer, kmd });

static fromConfig(config): AlgorandClient

Defined in: src/algorand-client.ts:383

Creates an AlgorandClient from the given config.

AlgoConfig

The config to use.

AlgorandClient

An instance of the AlgorandClient.

const client = AlgorandClient.fromConfig({ algodConfig, indexerConfig, kmdConfig });

static fromEnvironment(): AlgorandClient

Defined in: src/algorand-client.ts:372

Creates an AlgorandClient loading the configuration from environment variables.

Retrieve configurations from environment variables when defined or get default LocalNet configuration if they aren’t defined.

Expects to be called from a Node.js environment.

If process.env.ALGOD_SERVER is defined it will use that along with optional process.env.ALGOD_PORT and process.env.ALGOD_TOKEN.

If process.env.INDEXER_SERVER is defined it will use that along with optional process.env.INDEXER_PORT and process.env.INDEXER_TOKEN.

If either aren’t defined it will use the default LocalNet config.

It will return a KMD configuration that uses process.env.KMD_PORT (or port 4002) if process.env.ALGOD_SERVER is defined, otherwise it will use the default LocalNet config unless it detects testnet or mainnet.

AlgorandClient

An instance of the AlgorandClient.

const client = AlgorandClient.fromEnvironment();

static mainNet(): AlgorandClient

Defined in: src/algorand-client.ts:334

Creates an AlgorandClient pointing at MainNet using AlgoNode.

AlgorandClient

An instance of the AlgorandClient.

const algorand = AlgorandClient.mainNet();

static testNet(): AlgorandClient

Defined in: src/algorand-client.ts:320

Creates an AlgorandClient pointing at TestNet using AlgoNode.

AlgorandClient

An instance of the AlgorandClient.

const algorand = AlgorandClient.testNet();