supra-ts-sdk - v2.0.0
    Preparing search index...

    Class Block

    The Block class provides methods for querying block information on the Supra network.

    Hierarchy (View Summary)

    Index
    • The constructor function takes a NetworkConfig object as a parameter and assigns it to the networkInformation property.

      Parameters

      • networkInformation: NetworkConfig

        A NetworkConfig object that contains information about the network on which the Supra client is running.

      Returns Block

      import { SupraClient,Network } from "supra-ts-sdk";

      const supra = new SupraClient({ network: Network.TESTNET });
    • Get the meta information of the most recently finalized and executed block.

      Returns Promise<FinalizedBlockHeader>

      A Promise that resolves to a FinalizedBlockHeader object.

      import { SupraClient,Network } from "supra-ts-sdk";

      const supra = new SupraClient({ network: Network.TESTNET });

      async function runExample() {
      const block = await supra.block.getLatestBlock();
      console.log(block);
      }

      runExample().catch(console.error);
    • Get information about the block that has been finalized at the given height.

      Parameters

      • args: {
            height: number;
            options?: {
                withFinalizedTransactions?: boolean;
                type?: TransactionQueryType;
            };
        }
        • height: number

          The height of the block to retrieve.

        • Optionaloptions?: { withFinalizedTransactions?: boolean; type?: TransactionQueryType }
          • OptionalwithFinalizedTransactions?: boolean

            Whether to include the transactions in the block.

          • Optionaltype?: TransactionQueryType

            Include only the transactions of this type. "settlement" requires a node from v12 onwards; older nodes reject it with HTTP 400.

      Returns Promise<FinalizedBlockHeader>

      A Promise that resolves to a FinalizedBlockHeader object. Its transactions can contain any txn_type, including settlement items, which have no header, payload or authenticator.

      HTTP 404 when the node has no block at that height yet. A height that is not a number is HTTP 400 on v12 and HTTP 404 on v11. See "HTTP status codes by node version" in the README.

      import { SupraClient,Network } from "supra-ts-sdk";

      const supra = new SupraClient({ network: Network.TESTNET });

      async function runExample() {
      const height = 1;
      const block = await supra.block.getBlockByHeight({ height: height });
      console.log(block);
      }

      runExample().catch(console.error);
    • Get the header and execution output statistics of the block with the given hash.

      Parameters

      • args: { blockHash: string }
        • blockHash: string

          The hash of the block to retrieve.

      Returns Promise<FinalizedBlockHeader>

      A Promise that resolves to a FinalizedBlockHeader object.

      HTTP 404 for an unknown block. A hash that is not hexadecimal is HTTP 400 on v12 and HTTP 404 on v11. See "HTTP status codes by node version" in the README.

      import { SupraClient,Network } from "supra-ts-sdk";

      const supra = new SupraClient({ network: Network.TESTNET });

      async function runExample() {
      const blockHash = "0x1";
      const block = await supra.block.getBlockByHash({ blockHash: blockHash });
      console.log(block);
      }

      runExample().catch(console.error);
    • Get a list containing the hashes of the transactions that were finalized in the block with the given hash in the order that they were executed.

      Parameters

      • args: { blockHash: string; options?: { type?: TransactionQueryType } }
        • blockHash: string

          The hash of the block to retrieve.

        • Optionaloptions?: { type?: TransactionQueryType }
          • Optionaltype?: TransactionQueryType

            Return only the hashes of transactions of this type. "settlement" requires a node from v12 onwards; older nodes reject it with HTTP 400.

      Returns Promise<string[]>

      A Promise that resolves to a string array.

      HTTP 404 for an unknown block. A hash that is not hexadecimal is HTTP 400 on v12 and HTTP 404 on v11. See "HTTP status codes by node version" in the README.

      import { SupraClient,Network } from "supra-ts-sdk";

      const supra = new SupraClient({ network: Network.TESTNET });

      async function runExample() {
      const blockHash = "0x1";
      const transactions = await supra.block.getTransactionsByBlockHash({ blockHash: blockHash });
      console.log(transactions);
      }

      runExample().catch(console.error);