Class Algodv2

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



  • Create an AlgodClient from

    • either a token, baseServer, port, and optional headers
    • or a base client server for interoperability with external dApp wallets


    const token  = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    const server = "http://localhost";
    const port = 4001;
    const algodClient = new algosdk.Algodv2(token, server, port);


    The above configuration is for a sandbox private network. For applications on production, you are encouraged to run your own node, or use an Algorand REST API provider with a dedicated API key.


    • tokenOrBaseClient: string | BaseHTTPClient | AlgodTokenHeader | CustomTokenHeader

      The algod token from the Algorand node you are interacting with

    • baseServer: string

      REST endpoint

    • Optional port: string | number

      Port number if specifically configured by the server

    • headers: Record<string, string> = {}

      Optional headers

    Returns Algodv2

GET Methods

  • Returns a Merkle proof for a given transaction in a block.


    const round = 18038133;
    const proof = await algodClient.getTransactionProof(round, txId).do();

    Response data schema details


    • round: number

      The round in which the transaction appears.

    • txID: string

      The transaction ID for which to generate a proof.

    Returns GetTransactionProof

  • 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.

    Example 1

    const pendingTxnsByAddr = await algodClient.pendingTransactionByAddress(address).do();

    Example 2

    const maxTxns = 5;
    const pendingTxns = await algodClient

    Response data schema details


    • address: string

      The address of the sender.

    Returns PendingTransactionsByAddress

  • Returns the transaction information for a specific pending transaction.


    const pending = await algodClient.pendingTransactionInformation(txId).do();

    Response data schema details


    There are several cases when this might succeed:

    • transaction committed (committed round > 0)
    • transaction still in the pool (committed round = 0, pool error = "")
    • transaction removed from pool due to error (committed round = 0, pool error != "")

    Or the transaction may have happened sufficiently long ago that the node no longer remembers it, and this will return an error.


    • txid: string

      The TxID string of the pending transaction to look up.

    Returns PendingTransactionInformation

Other Methods

  • Given the program bytes, return the TEAL source code in plain text.


    const bytecode = "TEAL bytecode";
    const disassembledSource = await algodClient.disassemble(bytecode).do();


    This endpoint is only enabled when a node's configuration file sets EnableDeveloperAPI to true.


    • source: string | Uint8Array

    Returns Disassemble

  • Set the default int decoding method for all JSON requests this client creates.


    • method: IntDecoding

      {"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.

    Returns void

POST Methods

  • Compiles TEAL source code to binary, returns base64 encoded program bytes and base32 SHA512_256 hash of program bytes (Address style).


    const source = "TEAL SOURCE CODE";
    const compiledSmartContract = await algodClient.compile(source).do();

    Response data schema details


    This endpoint is only enabled when a node's configuration file sets EnableDeveloperAPI to true.


    • source: string | Uint8Array

    Returns Compile

Generated using TypeDoc