AlgorandClient
Defined in: src/algorand-client.ts:19
A client that brokers easy access to Algorand functionality.
Accessors
Section titled “Accessors”account
Section titled “account”Get Signature
Section titled “Get Signature”get account():
AccountManager
Defined in: src/algorand-client.ts:185
Get or create accounts that can sign transactions.
Example
Section titled “Example”const accountManager = AlgorandClient.mainNet().account;Returns
Section titled “Returns”The AccountManager instance.
Get Signature
Section titled “Get Signature”get app():
AppManager
Defined in: src/algorand-client.ts:205
Methods for interacting with apps.
Example
Section titled “Example”const appManager = AlgorandClient.mainNet().app;Returns
Section titled “Returns”The AppManager instance.
appDeployer
Section titled “appDeployer”Get Signature
Section titled “Get Signature”get appDeployer():
AppDeployer
Defined in: src/algorand-client.ts:215
Methods for deploying apps and managing app deployment metadata.
Example
Section titled “Example”const deployer = AlgorandClient.mainNet().appDeployer;Returns
Section titled “Returns”The AppDeployer instance.
Get Signature
Section titled “Get Signature”get asset():
AssetManager
Defined in: src/algorand-client.ts:195
Methods for interacting with assets.
Example
Section titled “Example”const assetManager = AlgorandClient.mainNet().asset;Returns
Section titled “Returns”The AssetManager instance.
client
Section titled “client”Get Signature
Section titled “Get Signature”get client():
ClientManager
Defined in: src/algorand-client.ts:175
Get clients, including algosdk clients and app clients.
Example
Section titled “Example”const clientManager = AlgorandClient.mainNet().client;Returns
Section titled “Returns”The ClientManager instance.
createTransaction
Section titled “createTransaction”Get Signature
Section titled “Get Signature”get createTransaction():
AlgorandClientTransactionCreator
Defined in: src/algorand-client.ts:293
Methods for creating a transaction.
Example
Section titled “Example”const payment = await AlgorandClient.mainNet().createTransaction.payment({ sender: "SENDERADDRESS", receiver: "RECEIVERADDRESS", amount: algo(1)})Returns
Section titled “Returns”AlgorandClientTransactionCreator
The AlgorandClientTransactionCreator instance.
network
Section titled “network”Get Signature
Section titled “Get Signature”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.
Example
Section titled “Example”// Get last roundconst lastRound = await algorand.network.getLastRound()
// Wait for a specific roundawait algorand.network.waitUntilRound(1000n)
// LocalNet-specific: block warpawait algorand.network.localNet.blockWarp(100n)Returns
Section titled “Returns”The NetworkManager instance.
Get Signature
Section titled “Get Signature”get send():
AlgorandClientTransactionSender
Defined in: src/algorand-client.ts:279
Methods for sending a transaction.
Example
Section titled “Example”const result = await AlgorandClient.mainNet().send.payment({ sender: "SENDERADDRESS", receiver: "RECEIVERADDRESS", amount: algo(1)})Returns
Section titled “Returns”AlgorandClientTransactionSender
The AlgorandClientTransactionSender instance.
Methods
Section titled “Methods”getSuggestedParams()
Section titled “getSuggestedParams()”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)
Returns
Section titled “Returns”Promise<{ consensusVersion: string; fee: bigint; firstValid: bigint; flatFee: boolean; genesisHash: Uint8Array; genesisId: string; lastValid: bigint; minFee: bigint; }>
The suggested transaction parameters.
Example
Section titled “Example”const params = await AlgorandClient.mainNet().getSuggestedParams();newGroup()
Section titled “newGroup()”newGroup(
composerConfig?):TransactionComposer
Defined in: src/algorand-client.ts:257
Start a new TransactionComposer transaction group
Parameters
Section titled “Parameters”composerConfig?
Section titled “composerConfig?”Returns
Section titled “Returns”A new instance of TransactionComposer.
Example
Section titled “Example”{@includeCode ./algorand-client.spec.ts#example-newGroup}registerErrorTransformer()
Section titled “registerErrorTransformer()”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
Parameters
Section titled “Parameters”transformer
Section titled “transformer”Returns
Section titled “Returns”void
setDefaultSigner()
Section titled “setDefaultSigner()”setDefaultSigner(
signer):AlgorandClient
Defined in: src/algorand-client.ts:77
Sets the default signer to use if no other signer is specified.
Parameters
Section titled “Parameters”signer
Section titled “signer”The signer to use, either a TransactionSigner or a AddressWithSigner
AddressWithTransactionSigner | TransactionSigner
Returns
Section titled “Returns”AlgorandClient
The AlgorandClient so method calls can be chained
Example
Section titled “Example”const signer = new SigningAccount(account, account.addr)const algorand = AlgorandClient.mainNet().setDefaultSigner(signer)setDefaultValidityWindow()
Section titled “setDefaultValidityWindow()”setDefaultValidityWindow(
validityWindow):AlgorandClient
Defined in: src/algorand-client.ts:62
Sets the default validity window for transactions.
Parameters
Section titled “Parameters”validityWindow
Section titled “validityWindow”The number of rounds between the first and last valid rounds
number | bigint
Returns
Section titled “Returns”AlgorandClient
The AlgorandClient so method calls can be chained
Example
Section titled “Example”const algorand = AlgorandClient.mainNet().setDefaultValidityWindow(1000);setSigner()
Section titled “setSigner()”setSigner(
sender,signer):AlgorandClient
Defined in: src/algorand-client.ts:113
Tracks the given signer against the given sender for later signing.
Parameters
Section titled “Parameters”sender
Section titled “sender”The sender address to use this signer for
string | Address
signer
Section titled “signer”The signer to sign transactions with for the given sender
Returns
Section titled “Returns”AlgorandClient
The AlgorandClient so method calls can be chained
Example
Section titled “Example”const signer = new SigningAccount(account, account.addr)const algorand = AlgorandClient.mainNet().setSigner(signer.addr, signer.signer)setSignerFromAccount()
Section titled “setSignerFromAccount()”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.
Parameters
Section titled “Parameters”account
Section titled “account”The account to register, which can be a AddressWithSigner or
a algosdk.Account, algosdk.LogicSigAccount, SigningAccount or MultisigAccount
MultisigAccount | AddressWithTransactionSigner | LogicSigAccount
Returns
Section titled “Returns”AlgorandClient
The AlgorandClient so method calls can be chained
Example
Section titled “Example”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()
Section titled “setSuggestedParamsCache()”setSuggestedParamsCache(
suggestedParams,until?):AlgorandClient
Defined in: src/algorand-client.ts:128
Sets a cache value to use for suggested transaction params.
Parameters
Section titled “Parameters”suggestedParams
Section titled “suggestedParams”The suggested params to use
consensusVersion
Section titled “consensusVersion”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.
firstValid
Section titled “firstValid”bigint
flatFee
Section titled “flatFee”boolean
genesisHash
Section titled “genesisHash”Uint8Array
GenesisHash is the hash of the genesis block.
genesisId
Section titled “genesisId”string
GenesisID is an ID listed in the genesis block.
lastValid
Section titled “lastValid”bigint
minFee
Section titled “minFee”bigint
The minimum transaction fee (not per byte) required for the txn to validate for the current network protocol.
until?
Section titled “until?”Date
A date until which to cache, or if not specified then the timeout is used
Returns
Section titled “Returns”AlgorandClient
The AlgorandClient so method calls can be chained
Example
Section titled “Example”const algorand = AlgorandClient.mainNet().setSuggestedParamsCache(suggestedParams, new Date(+new Date() + 3_600_000))setSuggestedParamsCacheTimeout()
Section titled “setSuggestedParamsCacheTimeout()”setSuggestedParamsCacheTimeout(
timeout):AlgorandClient
Defined in: src/algorand-client.ts:143
Sets the timeout for caching suggested params.
Parameters
Section titled “Parameters”timeout
Section titled “timeout”number
The timeout in milliseconds
Returns
Section titled “Returns”AlgorandClient
The AlgorandClient so method calls can be chained
Example
Section titled “Example”const algorand = AlgorandClient.mainNet().setSuggestedParamsCacheTimeout(10_000)unregisterErrorTransformer()
Section titled “unregisterErrorTransformer()”unregisterErrorTransformer(
transformer):void
Defined in: src/algorand-client.ts:247
Parameters
Section titled “Parameters”transformer
Section titled “transformer”Returns
Section titled “Returns”void
defaultLocalNet()
Section titled “defaultLocalNet()”
staticdefaultLocalNet():AlgorandClient
Defined in: src/algorand-client.ts:306
Creates an AlgorandClient pointing at default LocalNet ports and API token.
Returns
Section titled “Returns”AlgorandClient
An instance of the AlgorandClient.
Example
Section titled “Example”{@includeCode ./algorand-client.spec.ts#example-defaultLocalNet}fromClients()
Section titled “fromClients()”
staticfromClients(clients):AlgorandClient
Defined in: src/algorand-client.ts:349
Creates an AlgorandClient pointing to the given client(s).
Parameters
Section titled “Parameters”clients
Section titled “clients”The clients to use.
Returns
Section titled “Returns”AlgorandClient
An instance of the AlgorandClient.
Example
Section titled “Example”const algorand = AlgorandClient.fromClients({ algod, indexer, kmd });fromConfig()
Section titled “fromConfig()”
staticfromConfig(config):AlgorandClient
Defined in: src/algorand-client.ts:383
Creates an AlgorandClient from the given config.
Parameters
Section titled “Parameters”config
Section titled “config”The config to use.
Returns
Section titled “Returns”AlgorandClient
An instance of the AlgorandClient.
Example
Section titled “Example”const client = AlgorandClient.fromConfig({ algodConfig, indexerConfig, kmdConfig });fromEnvironment()
Section titled “fromEnvironment()”
staticfromEnvironment():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.
Returns
Section titled “Returns”AlgorandClient
An instance of the AlgorandClient.
Example
Section titled “Example”const client = AlgorandClient.fromEnvironment();mainNet()
Section titled “mainNet()”
staticmainNet():AlgorandClient
Defined in: src/algorand-client.ts:334
Creates an AlgorandClient pointing at MainNet using AlgoNode.
Returns
Section titled “Returns”AlgorandClient
An instance of the AlgorandClient.
Example
Section titled “Example”const algorand = AlgorandClient.mainNet();testNet()
Section titled “testNet()”
statictestNet():AlgorandClient
Defined in: src/algorand-client.ts:320
Creates an AlgorandClient pointing at TestNet using AlgoNode.
Returns
Section titled “Returns”AlgorandClient
An instance of the AlgorandClient.
Example
Section titled “Example”const algorand = AlgorandClient.testNet();