A class to query all Account related queries on Aptos.

Hierarchy (View Summary)

Account

  • Creates an instance of the Aptos client with the provided configuration.

    Parameters

    • config: AptosConfig

      The configuration settings for the Aptos client.

    Returns Account

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

    async function runExample() {
    // Initialize the Aptos client with testnet configuration
    const config = new AptosConfig({ network: Network.TESTNET }); // specify your own network if needed
    const aptos = new Aptos(config);

    console.log("Aptos client initialized:", aptos);
    }
    runExample().catch(console.error);
  • Derives an account by providing a private key. This function resolves the provided private key type and derives the public key from it.

    If the privateKey is a Secp256k1 type, it derives the account using the derived public key and auth key using the SingleKey scheme locally. If the privateKey is an ED25519 type, it looks up the authentication key on chain to determine whether it is a Legacy ED25519 key or a Unified ED25519 key, and then derives the account based on that.

    Parameters

    • args: { privateKey: PrivateKey }

      The arguments for deriving the account.

    Returns Promise<Account>

    The derived Account type.

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

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

    async function runExample() {
    // Deriving an account from a private key
    const account = await aptos.deriveAccountFromPrivateKey({
    privateKey: new Ed25519PrivateKey("0x123") // replace with a real private key
    });

    console.log(account);
    }
    runExample().catch(console.error);
  • Retrieves the current amount of APT for a specified account. If the account does not exist, it will return 0.

    Parameters

    • args: { accountAddress: AccountAddressInput; minimumLedgerVersion?: AnyNumber }

      The arguments for the account query.

      • accountAddress: AccountAddressInput

        The account address for which to retrieve the APT amount.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

    Returns Promise<number>

    The current amount of APT for the specified account.

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

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

    async function runExample() {
    // Get the APT amount for a specific account
    const accountAPTAmount = await aptos.getAccountAPTAmount({ accountAddress: "0x1" }); // replace with a real account address
    console.log("Account APT Amount:", accountAPTAmount);
    }
    runExample().catch(console.error);
  • Queries the current amount of a specified coin held by an account.

    Parameters

    • args: {
          accountAddress: AccountAddressInput;
          coinType?: `${string}::${string}::${string}`;
          faMetadataAddress?: AccountAddressInput;
          minimumLedgerVersion?: AnyNumber;
      }

      The parameters for querying the account's coin amount.

      • accountAddress: AccountAddressInput

        The account address to query for the coin amount.

      • OptionalcoinType?: `${string}::${string}::${string}`

        The coin type to query. Note: If not provided, it may be automatically populated if faMetadataAddress is specified.

      • OptionalfaMetadataAddress?: AccountAddressInput

        The fungible asset metadata address to query. Note: If not provided, it may be automatically populated if coinType is specified.

      • OptionalminimumLedgerVersion?: AnyNumber

        Not used anymore, here for backward compatibility see https://github.com/aptos-labs/aptos-ts-sdk/pull/519, will be removed in the near future. Optional ledger version to sync up to before querying.

    Returns Promise<number>

    The current amount of the specified coin held by the account.

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

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

    async function runExample() {
    // Query the account's coin amount for a specific coin type
    const accountCoinAmount = await aptos.getAccountCoinAmount({
    accountAddress: "0x1", // replace with a real account address
    coinType: "0x1::aptos_coin::AptosCoin" // specify the coin type
    });

    console.log(`Account coin amount: ${accountCoinAmount}`);
    }
    runExample().catch(console.error);
  • Retrieves the current count of an account's coins aggregated across all types.

    Parameters

    • args: { accountAddress: AccountAddressInput; minimumLedgerVersion?: AnyNumber }

      The parameters for the account coins count query.

      • accountAddress: AccountAddressInput

        The account address we want to get the total count for.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

    Returns Promise<number>

    The current count of the aggregated coins for the specified account.

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

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

    async function runExample() {
    // Getting the account coins count for a specific account
    const accountCoinsCount = await aptos.getAccountCoinsCount({ accountAddress: "0x1" }); // replace with a real account address
    console.log("Account Coins Count:", accountCoinsCount);
    }
    runExample().catch(console.error);
  • Retrieves the coins data for a specified account.

    Parameters

    • args: {
          accountAddress: AccountAddressInput;
          minimumLedgerVersion?: AnyNumber;
          options?: PaginationArgs & OrderByArg<
              {
                  amount?: any;
                  asset_type?: null
                  | string;
                  is_frozen: boolean;
                  is_primary?: null | boolean;
                  last_transaction_timestamp?: any;
                  last_transaction_version?: any;
                  metadata?:
                      | null
                      | {
                          asset_type: string;
                          creator_address: string;
                          decimals: number;
                          icon_uri?: null
                          | string;
                          last_transaction_timestamp: any;
                          last_transaction_version: any;
                          name: string;
                          project_uri?: null | string;
                          supply_aggregator_table_handle_v1?: null | string;
                          supply_aggregator_table_key_v1?: null | string;
                          symbol: string;
                          token_standard: string;
                      };
                  owner_address: string;
                  storage_id: string;
                  token_standard?: null
                  | string;
              },
          > & WhereArg<CurrentFungibleAssetBalancesBoolExp>;
      }
      • accountAddress: AccountAddressInput

        The account address for which to retrieve the coin's data.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: PaginationArgs & OrderByArg<
            {
                amount?: any;
                asset_type?: null
                | string;
                is_frozen: boolean;
                is_primary?: null | boolean;
                last_transaction_timestamp?: any;
                last_transaction_version?: any;
                metadata?:
                    | null
                    | {
                        asset_type: string;
                        creator_address: string;
                        decimals: number;
                        icon_uri?: null
                        | string;
                        last_transaction_timestamp: any;
                        last_transaction_version: any;
                        name: string;
                        project_uri?: null | string;
                        supply_aggregator_table_handle_v1?: null | string;
                        supply_aggregator_table_key_v1?: null | string;
                        symbol: string;
                        token_standard: string;
                    };
                owner_address: string;
                storage_id: string;
                token_standard?: null
                | string;
            },
        > & WhereArg<CurrentFungibleAssetBalancesBoolExp>

    Returns Promise<
        {
            amount?: any;
            asset_type?: null
            | string;
            is_frozen: boolean;
            is_primary?: null | boolean;
            last_transaction_timestamp?: any;
            last_transaction_version?: any;
            metadata?:
                | null
                | {
                    asset_type: string;
                    creator_address: string;
                    decimals: number;
                    icon_uri?: null
                    | string;
                    last_transaction_timestamp: any;
                    last_transaction_version: any;
                    name: string;
                    project_uri?: null | string;
                    supply_aggregator_table_handle_v1?: null | string;
                    supply_aggregator_table_key_v1?: null | string;
                    symbol: string;
                    token_standard: string;
                };
            owner_address: string;
            storage_id: string;
            token_standard?: null
            | string;
        }[],
    >

    An array containing the coins data for the specified account.

    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 coins data for a specific account
    const accountCoinsData = await aptos.getAccountCoinsData({
    accountAddress: "0x1", // replace with a real account address
    options: {
    limit: 10, // specify the number of results to return
    orderBy: { asset_type: "asc" }, // specify the order of results
    },
    });

    console.log(accountCoinsData);
    }
    runExample().catch(console.error);
  • Queries for all collections that an account currently has tokens for, including NFTs, fungible tokens, and soulbound tokens. If you want to filter by a specific token standard, you can pass an optional tokenStandard parameter.

    Parameters

    • args: {
          accountAddress: AccountAddressInput;
          minimumLedgerVersion?: AnyNumber;
          options?: TokenStandardArg & PaginationArgs & OrderByArg<
              {
                  collection_id?: null
                  | string;
                  collection_name?: null | string;
                  collection_uri?: null | string;
                  creator_address?: null | string;
                  current_collection?:
                      | null
                      | {
                          collection_id: string;
                          collection_name: string;
                          creator_address: string;
                          current_supply: any;
                          description: string;
                          last_transaction_timestamp: any;
                          last_transaction_version: any;
                          max_supply?: any;
                          mutable_description?: null
                          | boolean;
                          mutable_uri?: null | boolean;
                          table_handle_v1?: null | string;
                          token_standard: string;
                          total_minted_v2?: any;
                          uri: string;
                      };
                  distinct_tokens?: any;
                  last_transaction_version?: any;
                  owner_address?: null
                  | string;
                  single_token_uri?: null | string;
              },
          >;
      }
      • accountAddress: AccountAddressInput

        The account address we want to get the collections for.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: TokenStandardArg & PaginationArgs & OrderByArg<
            {
                collection_id?: null
                | string;
                collection_name?: null | string;
                collection_uri?: null | string;
                creator_address?: null | string;
                current_collection?:
                    | null
                    | {
                        collection_id: string;
                        collection_name: string;
                        creator_address: string;
                        current_supply: any;
                        description: string;
                        last_transaction_timestamp: any;
                        last_transaction_version: any;
                        max_supply?: any;
                        mutable_description?: null
                        | boolean;
                        mutable_uri?: null | boolean;
                        table_handle_v1?: null | string;
                        token_standard: string;
                        total_minted_v2?: any;
                        uri: string;
                    };
                distinct_tokens?: any;
                last_transaction_version?: any;
                owner_address?: null
                | string;
                single_token_uri?: null | string;
            },
        >

    Returns Promise<
        {
            collection_id?: null
            | string;
            collection_name?: null | string;
            collection_uri?: null | string;
            creator_address?: null | string;
            current_collection?:
                | null
                | {
                    collection_id: string;
                    collection_name: string;
                    creator_address: string;
                    current_supply: any;
                    description: string;
                    last_transaction_timestamp: any;
                    last_transaction_version: any;
                    max_supply?: any;
                    mutable_description?: null
                    | boolean;
                    mutable_uri?: null | boolean;
                    table_handle_v1?: null | string;
                    token_standard: string;
                    total_minted_v2?: any;
                    uri: string;
                };
            distinct_tokens?: any;
            last_transaction_version?: any;
            owner_address?: null
            | string;
            single_token_uri?: null | string;
        }[],
    >

    Collections array with the collections data.

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

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

    async function runExample() {
    // Get account collections with owned tokens for a specific account
    const accountCollectionsWithOwnedTokens = await aptos.getAccountCollectionsWithOwnedTokens({
    accountAddress: "0x1", // replace with a real account address
    options: {
    tokenStandard: "NFT", // specify the token standard if needed
    limit: 10, // specify the number of results to return
    },
    });

    console.log(accountCollectionsWithOwnedTokens);
    }
    runExample().catch(console.error);
  • Queries the current state for an Aptos account given its account address.

    Parameters

    Returns Promise<AccountData>

    The account data.

    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 account information for a specific address
    const accountInfo = await aptos.getAccountInfo({ accountAddress: "0x1" }); // replace with a real account address
    console.log(accountInfo);
    }
    runExample().catch(console.error);
  • Queries for a specific account module given an account address and module name.

    Parameters

    Returns Promise<MoveModuleBytecode>

    The account module associated with the specified account address and module name.

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

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

    async function runExample() {
    // Get the account module for a specific account address and module name
    const module = await aptos.getAccountModule({
    accountAddress: "0x1", // replace with a real account address
    moduleName: "MyModule" // specify the module name
    });

    console.log(module);
    }
    runExample().catch(console.error);
  • Queries for all modules in an account given an account address. This function may call the API multiple times to auto paginate through results.

    Parameters

    Returns Promise<MoveModuleBytecode[]>

    • The account modules associated with the specified address.
    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 account modules for a specific account
    const accountModules = await aptos.getAccountModules({
    accountAddress: "0x1", // replace with a real account address
    options: {
    limit: 10, // limiting to 10 modules
    },
    });

    console.log(accountModules);
    }
    runExample().catch(console.error);
  • Queries for a page of modules in an account given an account address.

    Parameters

    Returns Promise<{ cursor: undefined | string; modules: MoveModuleBytecode[] }>

    • The account modules associated with the specified address. Along with a cursor for future pagination. If the cursor is undefined, it means there are no more modules to fetch.
    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 account modules for a specific account
    const {modules, cursor} = await aptos.getAccountModulesPage({
    accountAddress: "0x1", // replace with a real account address
    options: {
    cursor: undefined, // starting from the first module
    limit: 10, // limiting to 10 modules
    },
    });

    console.log(modules);
    console.log(`More to fetch: ${cursor !== undefined}`);
    }
    runExample().catch(console.error);
  • Queries an account's owned objects.

    Parameters

    • args: {
          accountAddress: AccountAddressInput;
          minimumLedgerVersion?: AnyNumber;
          options?: PaginationArgs & OrderByArg<
              {
                  allow_ungated_transfer: boolean;
                  is_deleted: boolean;
                  last_guid_creation_num: any;
                  last_transaction_version: any;
                  object_address: string;
                  owner_address: string;
                  state_key_hash: string;
              },
          >;
      }
      • accountAddress: AccountAddressInput

        The account address we want to get the objects for.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: PaginationArgs & OrderByArg<
            {
                allow_ungated_transfer: boolean;
                is_deleted: boolean;
                last_guid_creation_num: any;
                last_transaction_version: any;
                object_address: string;
                owner_address: string;
                state_key_hash: string;
            },
        >

    Returns Promise<
        {
            allow_ungated_transfer: boolean;
            is_deleted: boolean;
            last_guid_creation_num: any;
            last_transaction_version: any;
            object_address: string;
            owner_address: string;
            state_key_hash: string;
        }[],
    >

    Objects array with the object data.

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

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

    async function runExample() {
    // Get the objects owned by the specified account
    const accountOwnedObjects = await aptos.getAccountOwnedObjects({
    accountAddress: "0x1", // replace with a real account address
    minimumLedgerVersion: 1, // optional, specify if needed
    options: {
    offset: 0, // optional, specify if needed
    limit: 10, // optional, specify if needed
    orderBy: "created_at", // optional, specify if needed
    },
    });

    console.log(accountOwnedObjects);
    }
    runExample().catch(console.error);
  • Queries the tokens currently owned by a specified account, including NFTs and fungible tokens. If desired, you can filter the results by a specific token standard.

    Parameters

    • args: {
          accountAddress: AccountAddressInput;
          minimumLedgerVersion?: AnyNumber;
          options?: TokenStandardArg & PaginationArgs & OrderByArg<
              {
                  amount: any;
                  current_token_data?: | null
                  | {
                      collection_id: string;
                      current_collection?: | null
                      | {
                          collection_id: string;
                          collection_name: string;
                          creator_address: string;
                          current_supply: any;
                          description: string;
                          last_transaction_timestamp: any;
                          last_transaction_version: any;
                          max_supply?: any;
                          mutable_description?: null
                          | boolean;
                          mutable_uri?: null | boolean;
                          table_handle_v1?: null | string;
                          token_standard: string;
                          total_minted_v2?: any;
                          uri: string;
                      };
                      decimals?: any;
                      description: string;
                      is_fungible_v2?: null
                      | boolean;
                      largest_property_version_v1?: any;
                      last_transaction_timestamp: any;
                      last_transaction_version: any;
                      maximum?: any;
                      supply?: any;
                      token_data_id: string;
                      token_name: string;
                      token_properties: any;
                      token_standard: string;
                      token_uri: string;
                  };
                  is_fungible_v2?: null
                  | boolean;
                  is_soulbound_v2?: null | boolean;
                  last_transaction_timestamp: any;
                  last_transaction_version: any;
                  owner_address: string;
                  property_version_v1: any;
                  storage_id: string;
                  table_type_v1?: null | string;
                  token_data_id: string;
                  token_properties_mutated_v1?: any;
                  token_standard: string;
              },
          >;
      }
      • accountAddress: AccountAddressInput

        The account address for which to retrieve owned tokens.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: TokenStandardArg & PaginationArgs & OrderByArg<
            {
                amount: any;
                current_token_data?: | null
                | {
                    collection_id: string;
                    current_collection?: | null
                    | {
                        collection_id: string;
                        collection_name: string;
                        creator_address: string;
                        current_supply: any;
                        description: string;
                        last_transaction_timestamp: any;
                        last_transaction_version: any;
                        max_supply?: any;
                        mutable_description?: null
                        | boolean;
                        mutable_uri?: null | boolean;
                        table_handle_v1?: null | string;
                        token_standard: string;
                        total_minted_v2?: any;
                        uri: string;
                    };
                    decimals?: any;
                    description: string;
                    is_fungible_v2?: null
                    | boolean;
                    largest_property_version_v1?: any;
                    last_transaction_timestamp: any;
                    last_transaction_version: any;
                    maximum?: any;
                    supply?: any;
                    token_data_id: string;
                    token_name: string;
                    token_properties: any;
                    token_standard: string;
                    token_uri: string;
                };
                is_fungible_v2?: null
                | boolean;
                is_soulbound_v2?: null | boolean;
                last_transaction_timestamp: any;
                last_transaction_version: any;
                owner_address: string;
                property_version_v1: any;
                storage_id: string;
                table_type_v1?: null | string;
                token_data_id: string;
                token_properties_mutated_v1?: any;
                token_standard: string;
            },
        >

    Returns Promise<
        {
            amount: any;
            current_token_data?: | null
            | {
                collection_id: string;
                current_collection?: | null
                | {
                    collection_id: string;
                    collection_name: string;
                    creator_address: string;
                    current_supply: any;
                    description: string;
                    last_transaction_timestamp: any;
                    last_transaction_version: any;
                    max_supply?: any;
                    mutable_description?: null
                    | boolean;
                    mutable_uri?: null | boolean;
                    table_handle_v1?: null | string;
                    token_standard: string;
                    total_minted_v2?: any;
                    uri: string;
                };
                decimals?: any;
                description: string;
                is_fungible_v2?: null
                | boolean;
                largest_property_version_v1?: any;
                last_transaction_timestamp: any;
                last_transaction_version: any;
                maximum?: any;
                supply?: any;
                token_data_id: string;
                token_name: string;
                token_properties: any;
                token_standard: string;
                token_uri: string;
            };
            is_fungible_v2?: null
            | boolean;
            is_soulbound_v2?: null | boolean;
            last_transaction_timestamp: any;
            last_transaction_version: any;
            owner_address: string;
            property_version_v1: any;
            storage_id: string;
            table_type_v1?: null | string;
            token_data_id: string;
            token_properties_mutated_v1?: any;
            token_standard: string;
        }[],
    >

    An array of tokens with their respective data.

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

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

    async function runExample() {
    // Get the tokens owned by a specific account
    const accountOwnedTokens = await aptos.getAccountOwnedTokens({
    accountAddress: "0x1", // replace with a real account address
    options: {
    limit: 10, // specify how many tokens to return
    orderBy: "created_at", // specify the order of the results
    },
    });

    console.log(accountOwnedTokens);
    }
    runExample().catch(console.error);
  • Queries all current tokens of a specific collection that an account owns by the collection address. This query returns all tokens (v1 and v2 standards) an account owns, including NFTs, fungible, soulbound, etc. If you want to get only the token from a specific standard, you can pass an optional tokenStandard parameter.

    Parameters

    • args: {
          accountAddress: AccountAddressInput;
          collectionAddress: AccountAddressInput;
          minimumLedgerVersion?: AnyNumber;
          options?: TokenStandardArg & PaginationArgs & OrderByArg<
              {
                  amount: any;
                  current_token_data?: | null
                  | {
                      collection_id: string;
                      current_collection?: | null
                      | {
                          collection_id: string;
                          collection_name: string;
                          creator_address: string;
                          current_supply: any;
                          description: string;
                          last_transaction_timestamp: any;
                          last_transaction_version: any;
                          max_supply?: any;
                          mutable_description?: null
                          | boolean;
                          mutable_uri?: null | boolean;
                          table_handle_v1?: null | string;
                          token_standard: string;
                          total_minted_v2?: any;
                          uri: string;
                      };
                      decimals?: any;
                      description: string;
                      is_fungible_v2?: null
                      | boolean;
                      largest_property_version_v1?: any;
                      last_transaction_timestamp: any;
                      last_transaction_version: any;
                      maximum?: any;
                      supply?: any;
                      token_data_id: string;
                      token_name: string;
                      token_properties: any;
                      token_standard: string;
                      token_uri: string;
                  };
                  is_fungible_v2?: null
                  | boolean;
                  is_soulbound_v2?: null | boolean;
                  last_transaction_timestamp: any;
                  last_transaction_version: any;
                  owner_address: string;
                  property_version_v1: any;
                  storage_id: string;
                  table_type_v1?: null | string;
                  token_data_id: string;
                  token_properties_mutated_v1?: any;
                  token_standard: string;
              },
          >;
      }
      • accountAddress: AccountAddressInput

        The account address we want to get the tokens for.

      • collectionAddress: AccountAddressInput

        The address of the collection being queried.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to, before querying.

      • Optionaloptions?: TokenStandardArg & PaginationArgs & OrderByArg<
            {
                amount: any;
                current_token_data?: | null
                | {
                    collection_id: string;
                    current_collection?: | null
                    | {
                        collection_id: string;
                        collection_name: string;
                        creator_address: string;
                        current_supply: any;
                        description: string;
                        last_transaction_timestamp: any;
                        last_transaction_version: any;
                        max_supply?: any;
                        mutable_description?: null
                        | boolean;
                        mutable_uri?: null | boolean;
                        table_handle_v1?: null | string;
                        token_standard: string;
                        total_minted_v2?: any;
                        uri: string;
                    };
                    decimals?: any;
                    description: string;
                    is_fungible_v2?: null
                    | boolean;
                    largest_property_version_v1?: any;
                    last_transaction_timestamp: any;
                    last_transaction_version: any;
                    maximum?: any;
                    supply?: any;
                    token_data_id: string;
                    token_name: string;
                    token_properties: any;
                    token_standard: string;
                    token_uri: string;
                };
                is_fungible_v2?: null
                | boolean;
                is_soulbound_v2?: null | boolean;
                last_transaction_timestamp: any;
                last_transaction_version: any;
                owner_address: string;
                property_version_v1: any;
                storage_id: string;
                table_type_v1?: null | string;
                token_data_id: string;
                token_properties_mutated_v1?: any;
                token_standard: string;
            },
        >

    Returns Promise<
        {
            amount: any;
            current_token_data?: | null
            | {
                collection_id: string;
                current_collection?: | null
                | {
                    collection_id: string;
                    collection_name: string;
                    creator_address: string;
                    current_supply: any;
                    description: string;
                    last_transaction_timestamp: any;
                    last_transaction_version: any;
                    max_supply?: any;
                    mutable_description?: null
                    | boolean;
                    mutable_uri?: null | boolean;
                    table_handle_v1?: null | string;
                    token_standard: string;
                    total_minted_v2?: any;
                    uri: string;
                };
                decimals?: any;
                description: string;
                is_fungible_v2?: null
                | boolean;
                largest_property_version_v1?: any;
                last_transaction_timestamp: any;
                last_transaction_version: any;
                maximum?: any;
                supply?: any;
                token_data_id: string;
                token_name: string;
                token_properties: any;
                token_standard: string;
                token_uri: string;
            };
            is_fungible_v2?: null
            | boolean;
            is_soulbound_v2?: null | boolean;
            last_transaction_timestamp: any;
            last_transaction_version: any;
            owner_address: string;
            property_version_v1: any;
            storage_id: string;
            table_type_v1?: null | string;
            token_data_id: string;
            token_properties_mutated_v1?: any;
            token_standard: string;
        }[],
    >

    Tokens array with the token data.

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

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

    async function runExample() {
    // Get tokens owned by a specific account in a specific collection
    const accountOwnedTokens = await aptos.getAccountOwnedTokensFromCollectionAddress({
    accountAddress: "0x1", // replace with a real account address
    collectionAddress: "0x2", // replace with a real collection address
    });

    console.log(accountOwnedTokens);
    }
    runExample().catch(console.error);
  • Queries a specific account resource given an account address and resource type.

    Type Parameters

    • T extends {} = any

      The typed output of the resource.

    Parameters

    • args: {
          accountAddress: AccountAddressInput;
          options?: LedgerVersionArg;
          resourceType: `${string}::${string}::${string}`;
      }
      • accountAddress: AccountAddressInput

        The Aptos account address to query.

      • Optionaloptions?: LedgerVersionArg
      • resourceType: `${string}::${string}::${string}`

        The string representation of an on-chain Move struct type, e.g., "0x1::aptos_coin::AptosCoin".

    Returns Promise<T>

    The account resource of the specified type.

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

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

    async function runExample() {
    // Get the account resource for a specific account address and resource type
    const resource = await aptos.getAccountResource({
    accountAddress: "0x1", // replace with a real account address
    resourceType: "0x1::aptos_coin::AptosCoin"
    });

    console.log(resource);
    }
    runExample().catch(console.error);
  • Queries all account resources given an account address. This function may call the API multiple times to auto paginate through results.

    Parameters

    Returns Promise<MoveResource[]>

    Account resources.

    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 account resources for a specific account address
    const resources = await aptos.getAccountResources({ accountAddress: "0x1" }); // replace with a real account address
    console.log(resources);
    }
    runExample().catch(console.error);
  • Queries a page of account resources given an account address.

    Parameters

    Returns Promise<{ cursor: undefined | string; resources: MoveResource[] }>

    Account resources.

    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 account resources for a specific account address
    const resources = await aptos.getAccountResourcesPage({
    accountAddress: "0x1", // replace with a real account address
    options: {
    cursor: undefined, // starting from the first resource
    limit: 10, // limiting to 10 resources
    },
    });
    console.log(resources);
    console.log(`More to fetch: ${resources.cursor !== undefined}`);
    }
    runExample().catch(console.error);
  • Queries the current count of tokens owned by a specified account.

    Parameters

    • args: { accountAddress: AccountAddressInput; minimumLedgerVersion?: AnyNumber }

      The parameters for the query.

      • accountAddress: AccountAddressInput

        The account address to query the token count for.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

    Returns Promise<number>

    The current count of tokens owned by the account.

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

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

    async function runExample() {
    // Get the count of tokens owned by the account
    const tokensCount = await aptos.getAccountTokensCount({ accountAddress: "0x1" }); // replace with a real account address
    console.log(`Tokens Count: ${tokensCount}`);
    }
    runExample().catch(console.error);
  • Queries account transactions given an account address. This function may call the API multiple times to auto paginate and retrieve all account transactions.

    Parameters

    Returns Promise<TransactionResponse[]>

    The account transactions.

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

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

    async function runExample() {
    // Fetch transactions for a specific account
    const transactions = await aptos.getAccountTransactions({
    accountAddress: "0x1", // replace with a real account address
    options: {
    offset: 0, // starting from the first transaction
    limit: 10, // limiting to 10 transactions
    },
    });

    console.log(transactions);
    }
    runExample().catch(console.error);
  • Queries the current count of transactions submitted by an account.

    Parameters

    • args: { accountAddress: AccountAddressInput; minimumLedgerVersion?: AnyNumber }

      The parameters for the query.

      • accountAddress: AccountAddressInput

        The account address we want to get the total count for.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

    Returns Promise<number>

    Current count of transactions made by an account.

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

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

    async function runExample() {
    // Get the count of transactions for a specific account
    const accountTransactionsCount = await aptos.getAccountTransactionsCount({
    accountAddress: "0x1", // replace with a real account address
    minimumLedgerVersion: 1, // specify your own minimum ledger version if needed
    });

    console.log(accountTransactionsCount);
    }
    runExample().catch(console.error);
  • Looks up the account address for a given authentication key, handling both rotated and non-rotated keys.

    Parameters

    Returns Promise<AccountAddress>

    Promise - The account address associated with the authentication key.

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

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

    async function runExample() {
    // Look up the original account address for a given authentication key
    const accountAddress = await aptos.lookupOriginalAccountAddress({
    authenticationKey: "0x1", // replace with a real authentication key
    });

    console.log("Original Account Address:", accountAddress);
    }
    runExample().catch(console.error);

Properties

abstraction: AccountAbstraction
config: AptosConfig

The configuration settings for the Aptos client.

MMNEPVFCICPMFPCPTTAAATR