A class to query all Table Aptos related queries.

Hierarchy (view full)

Properties

config: AptosConfig

Table

  • Initializes a new instance of the Aptos client with the specified configuration. This allows you to interact with the Aptos blockchain using the provided settings.

    Parameters

    • config: AptosConfig

      The configuration settings for the Aptos client.

    Returns Table

    import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";

    async function runExample() {
    // Create a new Aptos client with testnet configuration
    const config = new AptosConfig({ network: Network.TESTNET });
    const aptos = new Aptos(config);

    console.log("Aptos client initialized:", aptos);
    }
    runExample().catch(console.error);
  • Queries for a specific item in a table identified by the handle and the key for the item. This function allows you to retrieve structured data from a table in the Aptos blockchain.

    Type Parameters

    • T

    Parameters

    Returns Promise<T>

    Table item value rendered in JSON.

    import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";

    const config = new AptosConfig({ network: Network.TESTNET });
    const aptos = new Aptos(config);

    async function runExample() {
    // Retrieve a table item from the Aptos blockchain
    const tableItem = await aptos.getTableItem({
    handle: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca",
    data: {
    key_type: "address", // Move type of table key
    value_type: "u128", // Move type of table value
    key: "0x619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935" // Value of table key
    },
    });

    console.log(tableItem);
    }
    runExample().catch(console.error);
  • Queries for table items data with optional filtering and pagination. This function allows you to retrieve specific data from a table based on provided criteria.

    Parameters

    • args: {
          minimumLedgerVersion?: AnyNumber;
          options?: PaginationArgs & WhereArg<TableItemsBoolExp> & OrderByArg<{
              decoded_key: any;
              decoded_value?: any;
              key: string;
              table_handle: string;
              transaction_version: any;
              write_set_change_index: any;
          }>;
      }

      The arguments for querying table items data.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional minimum ledger version to wait for before querying.

      • Optionaloptions?: PaginationArgs & WhereArg<TableItemsBoolExp> & OrderByArg<{
            decoded_key: any;
            decoded_value?: any;
            key: string;
            table_handle: string;
            transaction_version: any;
            write_set_change_index: any;
        }>

        Optional parameters for pagination and filtering.

    Returns Promise<{
        decoded_key: any;
        decoded_value?: any;
        key: string;
        table_handle: string;
        transaction_version: any;
        write_set_change_index: any;
    }[]>

    GetTableItemsDataResponse

    import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";

    const config = new AptosConfig({ network: Network.TESTNET });
    const aptos = new Aptos(config);

    async function runExample() {
    // Retrieve table items data with specific filtering options
    const data = await aptos.getTableItemsData({
    minimumLedgerVersion: 1, // specify your own minimum ledger version if needed
    options: {
    where: {
    table_handle: { _eq: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca" },
    transaction_version: { _eq: "0" }
    },
    limit: 10, // specify your own limit if needed
    },
    });

    console.log(data);
    }
    runExample().catch(console.error);
  • Queries for the metadata of table items, allowing for filtering and pagination.

    Parameters

    Returns Promise<{
        handle: string;
        key_type: string;
        value_type: string;
    }[]>

    GetTableItemsMetadataResponse

    import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";

    const config = new AptosConfig({ network: Network.TESTNET });
    const aptos = new Aptos(config);

    async function runExample() {
    // Fetching table items metadata with a filter condition
    const data = await aptos.getTableItemsMetadata({
    minimumLedgerVersion: 1, // specify your own minimum ledger version if needed
    options: {
    where: { handle: { _eq: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca" } },
    limit: 10, // specify your own limit if needed
    },
    });

    console.log(data);
    }
    runExample().catch(console.error);
MMNEPVFCICPMFPCPTTAAATR