Create an AlgodClient from
const token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const server = "http://localhost";
const port = 4001;
const algodClient = new algosdk.Algodv2(token, server, port);
The algod token from the Algorand node you are interacting with
REST endpoint
Port number if specifically configured by the server
Optional headers
Returns the given account's application information for a specific application.
const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
const index = 60553466;
const accountInfo = await algodClient.accountApplicationInformation(address).do();
The address of the account to look up.
The application ID to look up.
Returns the given account's asset information for a specific asset.
const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
const index = 60553466;
const accountAssetInfo = await algodClient.accountAssetInformation(address, index).do();
The address of the account to look up.
The asset ID to look up.
Returns the given account's status, balance and spendable amounts.
const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
const accountInfo = await algodClient.accountInformation(address).do();
The address of the account to look up.
Returns the entire genesis file.
Given an application ID, return the application information including creator, approval and clear programs, global and local schemas, and global state.
const index = 60553466;
const app = await algodClient.getApplicationByID(index).do();
The application ID to look up.
Given an asset ID, return asset information including creator, name, total supply and special addresses.
const asset_id = 163650;
const asset = await algodClient.getAssetByID(asset_id).do();
The asset ID to look up.
Returns a Merkle proof for a given transaction in a block.
const round = 18038133;
const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA";
const proof = await algodClient.getProof(round, txId).do();
The round in which the transaction appears.
The transaction ID for which to generate a proof.
Returns the common needed parameters for a new transaction.
const suggestedParams = await algodClient.getTransactionParams().do();
const amountInMicroAlgos = algosdk.algosToMicroalgos(2); // 2 Algos
const unsignedTxn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
from: senderAddress,
to: receiverAddress,
amount: amountInMicroAlgos,
suggestedParams: suggestedParams,
});
Returns OK if healthy.
Returns the list of pending transactions sent by the address, sorted by priority, in decreasing order, truncated at the end at MAX. If MAX = 0, returns all pending transactions.
const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
const pendingTxnsByAddr = await algodClient.pendingTransactionByAddress(address).do();
const maxTxns = 5;
const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
const pendingTxns = await algodClient
.pendingTransactionByAddress(address)
.max(maxTxns)
.do();
The address of the sender.
Returns the transaction information for a specific pending transaction.
const txId = "DRJS6R745A7GFVMXEXWP4TGVDGKW7VILFTA7HC2BR2GRLHNY5CTA";
const pending = await algodClient.pendingTransactionInformation(txId).do();
The TxID string of the pending transaction to look up.
Returns the list of pending transactions in the pool, sorted by priority, in decreasing order, truncated at the end at MAX. If MAX = 0, returns all pending transactions.
Retrieves the StatusResponse from the running node.
Waits for a specific round to occur then returns the StatusResponse
for that round.
const round = 18038133;
const statusAfterBlock = await algodClient.statusAfterBlock(round).do();
The number of the round to wait for.
Returns the supply details for the specified node's ledger.
Get the default int decoding method for all JSON requests this client creates.
Set the default int decoding method for all JSON requests this client creates.
{"default" | "safe" | "mixed" | "bigint"} method The method to use when parsing the response for request. Must be one of "default", "safe", "mixed", or "bigint". See JSONRequest.setIntDecoding for more details about what each method does.
Provides debugging information for a transaction (or group).
Executes TEAL program(s) in context and returns debugging information about the execution. This endpoint is only enabled when a node's configureation file sets EnableDeveloperAPI
to true.
const dryRunResult = await algodClient.dryrun(dr).do();
Broadcasts a raw transaction to the network.
const { txId } = await algodClient.sendRawTransaction(signedTxns).do();
const result = await waitForConfirmation(algodClient, txid, 3);
Signed transactions
Generated using TypeDoc
Algod client connects an application to the Algorand blockchain. The algod client requires a valid algod REST endpoint IP address and algod token from an Algorand node that is connected to the network you plan to interact with.
Algod is the main Algorand process for handling the blockchain. Messages between nodes are processed, the protocol steps are executed, and the blocks are written to disk. The algod process also exposes a REST API server that developers can use to communicate with the node and the network. Algod uses the data directory for storage and configuration information.
Relevant Information
How do I obtain an algod address and token?
Run Algod in Postman OAS3