The main entry point for interacting with the Aptos APIs, providing access to various functionalities organized into distinct namespaces.

To utilize the SDK, instantiate a new Aptos object to gain access to the complete range of SDK features.

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

async function runExample() {
// Create a configuration for connecting to the Aptos testnet
const config = new AptosConfig({ network: Network.TESTNET });

// Initialize the Aptos client with the configuration
const aptos = new Aptos(config);

console.log("Aptos client initialized:", aptos);
}
runExample().catch(console.error);

Hierarchy (view full)

Constructors

Methods

addDigitalAssetPropertyTransaction addDigitalAssetTypedPropertyTransaction batchTransactionsForSingleAccount burnDigitalAssetTransaction createCollectionTransaction deriveAccountFromPrivateKey deriveKeylessAccount freezeDigitalAssetTransaferTransaction fundAccount getAccountAPTAmount getAccountCoinAmount getAccountCoinsCount getAccountCoinsData getAccountCollectionsWithOwnedTokens getAccountDomains getAccountEventsByCreationNumber getAccountEventsByEventType getAccountInfo getAccountModule getAccountModules getAccountNames getAccountOwnedObjects getAccountOwnedTokens getAccountOwnedTokensFromCollectionAddress getAccountResource getAccountResources getAccountSubdomains getAccountTokensCount getAccountTransactions getAccountTransactionsCount getBlockByHeight getBlockByVersion getChainId getChainTopUserTransactions getCollectionData getCollectionDataByCollectionId getCollectionDataByCreatorAddress getCollectionDataByCreatorAddressAndCollectionName getCollectionId getCurrentDigitalAssetOwnership getCurrentFungibleAssetBalances getDelegatedStakingActivities getDigitalAssetActivity getDigitalAssetData getDomainSubdomains getEvents getExpiration getFungibleAssetActivities getFungibleAssetMetadata getFungibleAssetMetadataByAssetType getFungibleAssetMetadataByCreatorAddress getGasPriceEstimation getIndexerLastSuccessVersion getLedgerInfo getModuleEventsByEventType getName getNumberOfDelegators getNumberOfDelegatorsForAllPools getObjectDataByObjectAddress getOwnedDigitalAssets getOwnerAddress getPepper getPrimaryName getProcessorStatus getProof getSigningMessage getTableItem getTableItemsData getTableItemsMetadata getTargetAddress getTransactionByHash getTransactionByVersion getTransactions isPendingTransaction lookupOriginalAccountAddress mintDigitalAssetTransaction mintSoulBoundTransaction publishPackageTransaction queryIndexer registerName removeDigitalAssetPropertyTransaction renewDomain rotateAuthKey setDigitalAssetDescriptionTransaction setDigitalAssetNameTransaction setDigitalAssetURITransaction setPrimaryName setTargetAddress sign signAndSubmitAsFeePayer signAndSubmitTransaction signAsFeePayer transferCoinTransaction transferDigitalAssetTransaction transferFungibleAsset unfreezeDigitalAssetTransaferTransaction updateDigitalAssetPropertyTransaction updateDigitalAssetTypedPropertyTransaction updateFederatedKeylessJwkSetTransaction view viewJson waitForTransaction

Properties

Constructors

  • Initializes a new instance of the Aptos client with the provided configuration settings. This allows you to interact with various Aptos functionalities such as accounts, transactions, and events.

    Parameters

    • Optionalsettings: AptosConfig

      Configuration settings for the Aptos client.

    Returns Aptos

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

    async function runExample() {
    // Create a new Aptos client with default settings
    const config = new AptosConfig({ network: Network.TESTNET }); // Specify your own settings if needed
    const aptos = new Aptos(config);

    console.log("Aptos client initialized:", aptos);
    }
    runExample().catch(console.error);

Methods

  • Add a digital asset property to the blockchain. This function allows you to specify a new property for a digital asset, including its key, type, and value.

    Parameters

    • args: {
          creator: Account;
          digitalAssetAddress: AccountAddressInput;
          digitalAssetType?: `${string}::${string}::${string}`;
          options?: InputGenerateTransactionOptions;
          propertyKey: string;
          propertyType:
              | "BOOLEAN"
              | "U8"
              | "U16"
              | "U32"
              | "U64"
              | "U128"
              | "U256"
              | "ADDRESS"
              | "STRING"
              | "ARRAY";
          propertyValue: PropertyValue;
      }

      The arguments for adding a digital asset property.

      • creator: Account

        The account that mints the digital asset.

      • digitalAssetAddress: AccountAddressInput

        The digital asset address.

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

        (Optional) The type of the digital asset.

      • Optionaloptions?: InputGenerateTransactionOptions

        (Optional) Options for generating the transaction.

      • propertyKey: string

        The property key for storing on-chain properties.

      • propertyType:
            | "BOOLEAN"
            | "U8"
            | "U16"
            | "U32"
            | "U64"
            | "U128"
            | "U256"
            | "ADDRESS"
            | "STRING"
            | "ARRAY"

        The type of property value.

      • propertyValue: PropertyValue

        The property value to be stored on-chain.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Add a digital asset property
    const transaction = await aptos.addDigitalAssetPropertyTransaction({
    creator: Account.generate(), // Replace with a real account
    propertyKey: "newKey",
    propertyType: "BOOLEAN",
    propertyValue: true,
    digitalAssetAddress: "0x123", // Replace with a real digital asset address
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Add a typed digital asset property to the blockchain. This function allows you to define and store a specific property for a digital asset, enabling better categorization and management of digital assets.

    Parameters

    • args: {
          creator: Account;
          digitalAssetAddress: AccountAddressInput;
          digitalAssetType?: `${string}::${string}::${string}`;
          options?: InputGenerateTransactionOptions;
          propertyKey: string;
          propertyType:
              | "BOOLEAN"
              | "U8"
              | "U16"
              | "U32"
              | "U64"
              | "U128"
              | "U256"
              | "ADDRESS"
              | "STRING"
              | "ARRAY";
          propertyValue: PropertyValue;
      }

      The parameters for adding the typed property.

      • creator: Account

        The account that mints the digital asset.

      • digitalAssetAddress: AccountAddressInput

        The digital asset address.

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

        The optional type of the digital asset.

      • Optionaloptions?: InputGenerateTransactionOptions

        Optional transaction generation options.

      • propertyKey: string

        The property key for storing on-chain properties.

      • propertyType:
            | "BOOLEAN"
            | "U8"
            | "U16"
            | "U32"
            | "U64"
            | "U128"
            | "U256"
            | "ADDRESS"
            | "STRING"
            | "ARRAY"

        The type of property value.

      • propertyValue: PropertyValue

        The property value to be stored on-chain.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Adding a typed digital asset property
    const transaction = await aptos.addDigitalAssetTypedPropertyTransaction({
    creator: Account.generate(), // replace with a real account
    propertyKey: "typedKey",
    propertyType: "STRING",
    propertyValue: "hello",
    digitalAssetAddress: "0x123", // replace with a real digital asset address
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Parameters

    Returns Promise<void>

    Prefer to use aptos.transaction.batch.forSingleAccount()

    Batch transactions for a single account by submitting multiple transaction payloads. This function is useful for efficiently processing and submitting transactions that do not depend on each other, such as batch funding or batch token minting.

    Error if any worker failure occurs during submission.

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

    const config = new AptosConfig({ network: Network.TESTNET });
    const aptos = new Aptos(config);
    const sender = Account.generate(); // Generate a new account for sending transactions

    async function runExample() {
    const transactions = [
    { }, // Build your first transaction payload
    { }, // Build your second transaction payload
    ];

    // Batch transactions for the single account
    await aptos.batchTransactionsForSingleAccount({
    sender,
    data: transactions,
    });

    console.log("Batch transactions submitted successfully.");
    }
    runExample().catch(console.error);
  • Burn a digital asset by its creator, allowing for the removal of a specified digital asset from the blockchain.

    Parameters

    • args: {
          creator: Account;
          digitalAssetAddress: AccountAddressInput;
          digitalAssetType?: `${string}::${string}::${string}`;
          options?: InputGenerateTransactionOptions;
      }

      The arguments for burning the digital asset.

      • creator: Account

        The creator account that is burning the digital asset.

      • digitalAssetAddress: AccountAddressInput

        The address of the digital asset to be burned.

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

        Optional. The type of the digital asset being burned.

      • Optionaloptions?: InputGenerateTransactionOptions

        Optional. Additional options for generating the transaction.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    const creator = Account.generate(); // Replace with a real creator account
    const transaction = await aptos.burnDigitalAssetTransaction({
    creator: creator,
    digitalAssetAddress: "0x123", // Replace with a real digital asset address
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Creates a new collection within the specified account.

    Parameters

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that when submitted will create the collection.

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

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

    async function runExample() {
    // Creating a new collection transaction
    const transaction = await aptos.createCollectionTransaction({
    creator: Account.generate(), // Replace with a real account
    description: "A unique collection of digital assets.",
    name: "My Digital Collection",
    uri: "https://mycollection.com",
    });

    console.log("Transaction created:", transaction);
    }
    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);
  • Freeze the ability to transfer a specified digital asset. This function allows the creator to restrict the transfer capability of a digital asset.

    Parameters

    • args: {
          creator: Account;
          digitalAssetAddress: AccountAddressInput;
          digitalAssetType?: `${string}::${string}::${string}`;
          options?: InputGenerateTransactionOptions;
      }

      The arguments for freezing the digital asset transfer.

      • creator: Account

        The creator account initiating the freeze.

      • digitalAssetAddress: AccountAddressInput

        The address of the digital asset to be frozen.

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

        Optional. The type of the digital asset being frozen.

      • Optionaloptions?: InputGenerateTransactionOptions

        Optional. Additional options for generating the transaction.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Freeze the digital asset transfer
    const transaction = await aptos.freezeDigitalAssetTransaferTransaction({
    creator: Account.generate(), // Replace with a real account if needed
    digitalAssetAddress: "0x123", // Replace with a real digital asset address
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • This function creates an account if it does not exist and mints the specified amount of coins into that account.

    Parameters

    Returns Promise<UserTransactionResponse>

    Transaction hash of the transaction that funded 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() {
    // Fund an account with a specified amount of tokens
    const transaction = await aptos.fundAccount({
    accountAddress: "0x1", // replace with your account address
    amount: 100,
    });

    console.log("Transaction hash:", transaction.hash);
    }
    runExample().catch(console.error);
  • Retrieves the current amount of APT for a specified account.

    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);
  • Fetches all top-level domain names for a specified account.

    Parameters

    Returns Promise<{
        domain?: null | string;
        domain_expiration_timestamp?: any;
        expiration_timestamp?: any;
        is_primary?: null | boolean;
        owner_address?: null | string;
        registered_address?: null | string;
        subdomain?: null | string;
        subdomain_expiration_policy?: any;
        token_standard?: null | string;
    }[]>

    A promise of an array of ANSName.

    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 all top-level domain names for a specific account
    const domains = await aptos.getAccountDomains({
    accountAddress: "0x1", // replace with a real account address
    options: {
    limit: 10, // specify the number of names to fetch
    offset: 0, // specify the offset for pagination
    orderBy: "created_at", // specify the order by which to sort the names
    where: {
    // additional filters can be specified here
    },
    },
    });

    console.log(domains);
    }
    runExample().catch(console.error);
  • Retrieve events associated with a specific account address and creation number.

    Parameters

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

      The parameters for retrieving account events.

      • accountAddress: AccountAddressInput

        The account address to query events for.

      • creationNumber: AnyNumber

        The event creation number to filter the events.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional minimum ledger version to sync up to before querying.

    Returns Promise<{
        account_address: string;
        creation_number: any;
        data: any;
        event_index: any;
        indexed_type: string;
        sequence_number: any;
        transaction_block_height: any;
        transaction_version: any;
        type: string;
    }[]>

    Promise

    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 events for the account at creation number 0
    const events = await aptos.getAccountEventsByCreationNumber({
    accountAddress: "0x1", // replace with a real account address
    creationNumber: 0,
    });

    console.log(events);
    }
    runExample().catch(console.error);
  • Retrieve events associated with a specific account address and event type.

    Parameters

    • args: {
          accountAddress: AccountAddressInput;
          eventType: `${string}::${string}::${string}`;
          minimumLedgerVersion?: AnyNumber;
          options?: PaginationArgs & OrderByArg<{
              account_address: string;
              creation_number: any;
              data: any;
              event_index: any;
              indexed_type: string;
              sequence_number: any;
              transaction_block_height: any;
              transaction_version: any;
              type: string;
          }>;
      }
      • accountAddress: AccountAddressInput

        The account address to query events for.

      • eventType: `${string}::${string}::${string}`

        The type of event to filter by.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: PaginationArgs & OrderByArg<{
            account_address: string;
            creation_number: any;
            data: any;
            event_index: any;
            indexed_type: string;
            sequence_number: any;
            transaction_block_height: any;
            transaction_version: any;
            type: string;
        }>

        Optional pagination and ordering parameters for the event query.

    Returns Promise<{
        account_address: string;
        creation_number: any;
        data: any;
        event_index: any;
        indexed_type: string;
        sequence_number: any;
        transaction_block_height: any;
        transaction_version: any;
        type: string;
    }[]>

    Promise

    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 events for a specific account and event type
    const events = await aptos.getAccountEventsByEventType({
    accountAddress: "0x1", // replace with a real account address
    eventType: "0x1::transaction_fee::FeeStatement", // replace with a real event type
    minimumLedgerVersion: 1, // optional, specify if needed
    });

    console.log(events);
    }
    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: {
    offset: 0, // starting from the first module
    limit: 10, // limiting to 10 modules
    },
    });

    console.log(accountModules);
    }
    runExample().catch(console.error);
  • Fetches all names for an account, including both top-level domains and subdomains.

    Parameters

    Returns Promise<{
        domain?: null | string;
        domain_expiration_timestamp?: any;
        expiration_timestamp?: any;
        is_primary?: null | boolean;
        owner_address?: null | string;
        registered_address?: null | string;
        subdomain?: null | string;
        subdomain_expiration_policy?: any;
        token_standard?: null | string;
    }[]>

    A promise of an array of ANSName.

    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 account names for a specific address
    const accountNames = await aptos.getAccountNames({
    accountAddress: "0x1", // replace with a real account address
    options: {
    limit: 10, // specify how many names to fetch
    orderBy: "name", // specify the order by which to sort the names
    },
    });

    console.log(accountNames);
    }
    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);
  • Fetches all subdomain names for a specified account.

    Parameters

    Returns Promise<{
        domain?: null | string;
        domain_expiration_timestamp?: any;
        expiration_timestamp?: any;
        is_primary?: null | boolean;
        owner_address?: null | string;
        registered_address?: null | string;
        subdomain?: null | string;
        subdomain_expiration_policy?: any;
        token_standard?: null | string;
    }[]>

    A promise of an array of ANSName.

    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 subdomain names for a specific account
    const subdomains = await aptos.getAccountSubdomains({
    accountAddress: "0x1", // replace with a real account address
    options: {
    limit: 10, // specify the number of subdomains to fetch
    offset: 0, // specify the offset for pagination
    orderBy: "name", // specify the order by which to sort the names
    },
    });

    console.log(subdomains);
    }
    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);
  • Retrieve a block by its height, allowing for the inclusion of transactions if specified.

    Parameters

    • args: {
          blockHeight: AnyNumber;
          options?: {
              withTransactions?: boolean;
          };
      }

      The parameters for the block retrieval.

      • blockHeight: AnyNumber

        The block height to look up, starting at 0.

      • Optionaloptions?: {
            withTransactions?: boolean;
        }

        Optional settings for the retrieval.

        • OptionalwithTransactions?: boolean

    Returns Promise<Block>

    The block with optional transactions included.

    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 the block at height 5, including transactions
    const block = await aptos.getBlockByHeight({ blockHeight: 5, options: { withTransactions: true } });
    console.log(block);
    }
    runExample().catch(console.error);
  • Retrieves block information by the specified ledger version.

    Parameters

    • args: {
          ledgerVersion: AnyNumber;
          options?: {
              withTransactions?: boolean;
          };
      }

      The arguments for retrieving the block.

      • ledgerVersion: AnyNumber

        The ledger version to lookup block information for.

      • Optionaloptions?: {
            withTransactions?: boolean;
        }

        Optional parameters for the request.

        • OptionalwithTransactions?: boolean

    Returns Promise<Block>

    Block information with optional 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() {
    // Retrieve block information for a specific ledger version
    const block = await aptos.getBlockByVersion({ ledgerVersion: 5 });
    console.log(block);
    }
    runExample().catch(console.error);
  • Retrieves the chain ID of the Aptos blockchain.

    Returns Promise<number>

    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 the chain ID
    const chainId = await aptos.getChainId();
    console.log("Chain ID:", chainId);
    }
    runExample().catch(console.error);

    @returns The chain ID of the Aptos blockchain.
  • Queries the top user transactions based on the specified limit.

    Parameters

    • args: {
          limit: number;
      }

      The arguments for querying top user transactions.

      • limit: number

        The number of transactions to return.

    Returns Promise<{
        version: any;
    }[]>

    GetChainTopUserTransactionsResponse

    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 the top user transactions with a limit of 5
    const topUserTransactions = await aptos.getChainTopUserTransactions({ limit: 5 });

    console.log(topUserTransactions);
    }
    runExample().catch(console.error);
  • Queries data of a specific collection by the collection creator address and the collection name. This function is deprecated; use getCollectionDataByCreatorAddressAndCollectionName instead.

    If a creator account has two collections with the same name in v1 and v2, you can pass an optional tokenStandard parameter to query a specific standard.

    Parameters

    • args: {
          collectionName: string;
          creatorAddress: AccountAddressInput;
          minimumLedgerVersion?: AnyNumber;
          options?: TokenStandardArg;
      }

      The arguments for querying the collection data.

      • collectionName: string

        The name of the collection.

      • creatorAddress: AccountAddressInput

        The address of the collection's creator.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: TokenStandardArg

        Optional parameters for the query.

    Returns Promise<{
        cdn_asset_uris?: null | {
            animation_optimizer_retry_count: number;
            asset_uri: string;
            cdn_animation_uri?: null | string;
            cdn_image_uri?: null | string;
            cdn_json_uri?: null | string;
            image_optimizer_retry_count: number;
            json_parser_retry_count: number;
            raw_animation_uri?: null | string;
            raw_image_uri?: null | string;
        };
        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;
    }>

    GetCollectionDataResponse - The response type containing the collection 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() {
    // Querying collection data by creator address and collection name
    const collection = await aptos.getCollectionData({
    creatorAddress: "0x1", // replace with a real creator address
    collectionName: "myCollection", // specify your collection name
    });

    console.log(collection);
    }
    runExample().catch(console.error);
  • Queries data of a specific collection by the collection ID.

    Parameters

    Returns Promise<{
        cdn_asset_uris?: null | {
            animation_optimizer_retry_count: number;
            asset_uri: string;
            cdn_animation_uri?: null | string;
            cdn_image_uri?: null | string;
            cdn_json_uri?: null | string;
            image_optimizer_retry_count: number;
            json_parser_retry_count: number;
            raw_animation_uri?: null | string;
            raw_image_uri?: null | string;
        };
        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;
    }>

    GetCollectionDataResponse - The response type containing the collection 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() {
    // Fetching collection data by collection ID
    const collection = await aptos.getCollectionDataByCollectionId({
    collectionId: "0x123", // replace with a real collection ID
    });

    console.log(collection);
    }
    runExample().catch(console.error);
  • Retrieves data for a specific collection created by a given creator address. This function allows you to query collection data while optionally specifying a minimum ledger version and pagination options.

    Parameters

    Returns Promise<{
        cdn_asset_uris?: null | {
            animation_optimizer_retry_count: number;
            asset_uri: string;
            cdn_animation_uri?: null | string;
            cdn_image_uri?: null | string;
            cdn_json_uri?: null | string;
            image_optimizer_retry_count: number;
            json_parser_retry_count: number;
            raw_animation_uri?: null | string;
            raw_image_uri?: null | string;
        };
        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;
    }>

    GetCollectionDataResponse - The response type containing collection 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 collection data by creator address
    const collectionData = await aptos.getCollectionDataByCreatorAddress({
    creatorAddress: "0x1", // replace with a real creator address
    minimumLedgerVersion: 1, // specify the minimum ledger version if needed
    options: {
    tokenStandard: "v2", // specify the token standard if needed
    pagination: { limit: 10, offset: 0 } // specify pagination options if needed
    }
    });

    console.log(collectionData);
    }
    runExample().catch(console.error);
  • Queries data of a specific collection by the collection creator address and the collection name. If a creator account has multiple collections with the same name across different versions, specify the tokenStandard parameter to query a specific standard.

    Parameters

    Returns Promise<{
        cdn_asset_uris?: null | {
            animation_optimizer_retry_count: number;
            asset_uri: string;
            cdn_animation_uri?: null | string;
            cdn_image_uri?: null | string;
            cdn_json_uri?: null | string;
            image_optimizer_retry_count: number;
            json_parser_retry_count: number;
            raw_animation_uri?: null | string;
            raw_image_uri?: null | string;
        };
        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;
    }>

    GetCollectionDataResponse - The response type containing collection 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() {
    // Fetching collection data by creator address and collection name
    const collection = await aptos.getCollectionDataByCreatorAddressAndCollectionName({
    creatorAddress: "0x1", // replace with a real creator address
    collectionName: "myCollection",
    minimumLedgerVersion: 1, // optional, specify if needed
    options: { tokenStandard: "v2" } // optional, specify if needed
    });

    console.log(collection);
    }
    runExample().catch(console.error);
  • Queries the ID of a specified collection. This ID corresponds to the collection's object address in V2, while V1 does not utilize objects and lacks an address.

    Parameters

    Returns Promise<string>

    The collection ID.

    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 the collection ID for a specific creator and collection name
    const collectionId = await aptos.getCollectionId({
    creatorAddress: "0x1", // replace with a real creator address
    collectionName: "myCollection"
    });

    console.log("Collection ID:", collectionId);
    }
    runExample().catch(console.error);
  • Retrieves the current ownership data of a specified digital asset using its address.

    Parameters

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

      The parameters for the request.

      • digitalAssetAddress: AccountAddressInput

        The address of the digital asset.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

    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;
    }>

    GetCurrentTokenOwnershipResponse containing relevant ownership data of the digital asset.

    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 current ownership of a digital asset
    const digitalAssetOwner = await aptos.getCurrentDigitalAssetOwnership({
    digitalAssetAddress: "0x123", // replace with a real digital asset address
    });

    console.log(digitalAssetOwner);
    }
    runExample().catch(console.error);
  • Queries all fungible asset balances.

    Parameters

    Returns Promise<{
        amount?: any;
        asset_type?: null | string;
        is_frozen: boolean;
        is_primary?: null | boolean;
        last_transaction_timestamp?: any;
        last_transaction_version?: any;
        owner_address: string;
        storage_id: string;
        token_standard?: null | string;
    }[]>

    A list of fungible asset metadata.

    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 current fungible asset balances
    const fungibleAssetBalances = await aptos.getCurrentFungibleAssetBalances();

    console.log(fungibleAssetBalances);
    }
    runExample().catch(console.error);
  • Queries delegated staking activities for a specific delegator and pool.

    Parameters

    Returns Promise<{
        amount: any;
        delegator_address: string;
        event_index: any;
        event_type: string;
        pool_address: string;
        transaction_version: any;
    }[]>

    The response containing delegated staking activities.

    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 delegated staking activities for a specific delegator and pool
    const activities = await aptos.getDelegatedStakingActivities({
    delegatorAddress: "0x1", // replace with a real delegator address
    poolAddress: "0x2", // replace with a real pool address
    minimumLedgerVersion: 1, // specify your own if needed
    });

    console.log(activities);
    }
    runExample().catch(console.error);
  • Retrieves the activity data for a specified digital asset using its address.

    Parameters

    • args: {
          digitalAssetAddress: AccountAddressInput;
          minimumLedgerVersion?: AnyNumber;
          options?: PaginationArgs & OrderByArg<{
              after_value?: null | string;
              before_value?: null | string;
              entry_function_id_str?: null | string;
              event_account_address: string;
              event_index: any;
              from_address?: null | string;
              is_fungible_v2?: null | boolean;
              property_version_v1: any;
              to_address?: null | string;
              token_amount: any;
              token_data_id: string;
              token_standard: string;
              transaction_timestamp: any;
              transaction_version: any;
              type: string;
          }>;
      }

      The parameters for the request.

      • digitalAssetAddress: AccountAddressInput

        The address of the digital asset.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional minimum ledger version to sync up to before querying.

      • Optionaloptions?: PaginationArgs & OrderByArg<{
            after_value?: null | string;
            before_value?: null | string;
            entry_function_id_str?: null | string;
            event_account_address: string;
            event_index: any;
            from_address?: null | string;
            is_fungible_v2?: null | boolean;
            property_version_v1: any;
            to_address?: null | string;
            token_amount: any;
            token_data_id: string;
            token_standard: string;
            transaction_timestamp: any;
            transaction_version: any;
            type: string;
        }>

        Optional pagination and ordering parameters.

    Returns Promise<{
        after_value?: null | string;
        before_value?: null | string;
        entry_function_id_str?: null | string;
        event_account_address: string;
        event_index: any;
        from_address?: null | string;
        is_fungible_v2?: null | boolean;
        property_version_v1: any;
        to_address?: null | string;
        token_amount: any;
        token_data_id: string;
        token_standard: string;
        transaction_timestamp: any;
        transaction_version: any;
        type: string;
    }[]>

    A promise that resolves to the activity data related to the digital asset.

    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 activity data for a digital asset
    const digitalAssetActivity = await aptos.getDigitalAssetActivity({
    digitalAssetAddress: "0x123", // replace with a real digital asset address
    });

    console.log(digitalAssetActivity);
    }
    runExample().catch(console.error);
  • Retrieves digital asset data using the address of a digital asset.

    Parameters

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

      The parameters for the request.

      • digitalAssetAddress: AccountAddressInput

        The address of the digital asset.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

    Returns Promise<{
        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;
    }>

    GetTokenDataResponse containing relevant data for the digital asset.

    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 digital asset data for a specific address
    const digitalAsset = await aptos.getDigitalAssetData({
    digitalAssetAddress: "0x123", // replace with a real digital asset address
    });

    console.log(digitalAsset);
    }
    runExample().catch(console.error);
  • Fetches all subdomain names for a given domain, excluding the domain itself.

    Parameters

    Returns Promise<{
        domain?: null | string;
        domain_expiration_timestamp?: any;
        expiration_timestamp?: any;
        is_primary?: null | boolean;
        owner_address?: null | string;
        registered_address?: null | string;
        subdomain?: null | string;
        subdomain_expiration_policy?: any;
        token_standard?: null | string;
    }[]>

    A promise that resolves to an array of ANSName.

    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 subdomains for a specific domain
    const subdomains = await aptos.getDomainSubdomains({
    domain: "test", // replace with your domain
    options: {
    limit: 10, // specify the number of subdomains to fetch
    offset: 0, // specify the starting point for fetching
    orderBy: "name", // specify the order by which to sort the results
    },
    });

    console.log(subdomains);
    }
    runExample().catch(console.error);
  • Retrieve all events from the Aptos blockchain. An optional where clause can be provided to filter the results based on specific criteria.

    Parameters

    • Optionalargs: {
          minimumLedgerVersion?: AnyNumber;
          options?: PaginationArgs & OrderByArg<{
              account_address: string;
              creation_number: any;
              data: any;
              event_index: any;
              indexed_type: string;
              sequence_number: any;
              transaction_block_height: any;
              transaction_version: any;
              type: string;
          }> & WhereArg<EventsBoolExp>;
      }

      Optional parameters for the query.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: PaginationArgs & OrderByArg<{
            account_address: string;
            creation_number: any;
            data: any;
            event_index: any;
            indexed_type: string;
            sequence_number: any;
            transaction_block_height: any;
            transaction_version: any;
            type: string;
        }> & WhereArg<EventsBoolExp>

        Optional pagination and filtering options.

    Returns Promise<{
        account_address: string;
        creation_number: any;
        data: any;
        event_index: any;
        indexed_type: string;
        sequence_number: any;
        transaction_block_height: any;
        transaction_version: any;
        type: string;
    }[]>

    GetEventsQuery response type containing the events.

    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 all events
    const events = await aptos.getEvents();

    // Retrieve events with filtering by account address
    const whereCondition = {
    account_address: { _eq: "0x123" }, // replace with a real account address
    };
    const filteredEvents = await aptos.getEvents({
    options: { where: whereCondition },
    });

    console.log(events);
    console.log(filteredEvents);
    }
    runExample().catch(console.error);
  • Retrieve the expiration time of a domain name or subdomain name from the contract.

    Parameters

    • args: {
          name: string;
      }

      The arguments for retrieving the expiration.

      • name: string

        A string of the name to retrieve.

    Returns Promise<undefined | number>

    number as a unix timestamp in milliseconds.

    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 expiration time for the domain "test.aptos"
    const exp = await aptos.getExpiration({ name: "test.aptos" });

    // Log the expiration date
    console.log(new Date(exp)); // Outputs the expiration date
    }
    runExample().catch(console.error);
  • Queries all fungible asset activities and returns a list of their metadata.

    Parameters

    Returns Promise<{
        amount?: any;
        asset_type?: null | string;
        block_height: any;
        entry_function_id_str?: null | string;
        event_index: any;
        gas_fee_payer_address?: null | string;
        is_frozen?: null | boolean;
        is_gas_fee: boolean;
        is_transaction_success: boolean;
        owner_address?: null | string;
        storage_id: string;
        storage_refund_amount: any;
        token_standard: string;
        transaction_timestamp: any;
        transaction_version: any;
        type: string;
    }[]>

    A list of fungible asset metadata.

    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 fungible asset activities
    const fungibleAssetActivities = await aptos.getFungibleAssetActivities();
    console.log(fungibleAssetActivities);
    }
    runExample().catch(console.error);
  • Queries all fungible asset metadata.

    Parameters

    Returns Promise<{
        asset_type: string;
        creator_address: string;
        decimals: number;
        icon_uri?: null | string;
        last_transaction_timestamp: any;
        last_transaction_version: any;
        maximum_v2?: any;
        name: string;
        project_uri?: null | string;
        supply_aggregator_table_handle_v1?: null | string;
        supply_aggregator_table_key_v1?: null | string;
        supply_v2?: any;
        symbol: string;
        token_standard: string;
    }[]>

    A list of fungible asset metadata.

    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 fungible asset metadata
    const fungibleAssets = await aptos.getFungibleAssetMetadata();
    console.log(fungibleAssets);
    }
    runExample().catch(console.error);
  • Queries the fungible asset metadata for a specific asset type. This function helps retrieve detailed information about a fungible asset based on its type.

    Parameters

    • args: {
          assetType: string;
          minimumLedgerVersion?: AnyNumber;
      }

      The parameters for the query.

      • assetType: string

        The asset type of the fungible asset, e.g., "0x1::aptos_coin::AptosCoin" for Aptos Coin.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

    Returns Promise<{
        asset_type: string;
        creator_address: string;
        decimals: number;
        icon_uri?: null | string;
        last_transaction_timestamp: any;
        last_transaction_version: any;
        maximum_v2?: any;
        name: string;
        project_uri?: null | string;
        supply_aggregator_table_handle_v1?: null | string;
        supply_aggregator_table_key_v1?: null | string;
        supply_v2?: any;
        symbol: string;
        token_standard: string;
    }>

    A fungible asset metadata item.

    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 fungible asset metadata by asset type
    const fungibleAsset = await aptos.getFungibleAssetMetadataByAssetType({
    assetType: "0x1::aptos_coin::AptosCoin" // replace with your asset type
    });

    console.log(fungibleAsset);
    }
    runExample().catch(console.error);
  • Retrieves fungible asset metadata based on the creator address.

    This function allows you to query metadata for a specific fungible asset created by a given address.

    Parameters

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

      The parameters for the query.

      • creatorAddress: AccountAddressInput

        The creator address of the fungible asset.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

    Returns Promise<{
        asset_type: string;
        creator_address: string;
        decimals: number;
        icon_uri?: null | string;
        last_transaction_timestamp: any;
        last_transaction_version: any;
        maximum_v2?: any;
        name: string;
        project_uri?: null | string;
        supply_aggregator_table_handle_v1?: null | string;
        supply_aggregator_table_key_v1?: null | string;
        supply_v2?: any;
        symbol: string;
        token_standard: string;
    }[]>

    A fungible asset metadata item.

    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 fungible asset metadata by creator address
    const fungibleAsset = await aptos.getFungibleAssetMetadataByCreatorAddress({
    creatorAddress: "0x123", // replace with a real creator address
    });

    console.log(fungibleAsset);
    }
    runExample().catch(console.error);
  • Estimates the gas unit price required to process a transaction on the Aptos blockchain in a timely manner. This helps users to understand the cost associated with their transactions. https://api.mainnet.aptoslabs.com/v1/spec#/operations/estimate_gas_price

    Returns Promise<GasEstimation>

    An object containing the estimated gas price.

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

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

    async function runExample() {
    // Getting the gas price estimation
    const gasPriceEstimation = await aptos.getGasPriceEstimation();

    console.log("Estimated Gas Price:", gasPriceEstimation);
    }
    runExample().catch(console.error);
  • Queries for the last successful indexer version, providing insight into the ledger version the indexer is updated to, which may lag behind the full nodes.

    Returns Promise<bigint>

    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 last successful indexer version
    const version = await aptos.getIndexerLastSuccessVersion();
    console.log(`Last successful indexer version: ${version}`);
    }
    runExample().catch(console.error);
  • Queries for the Aptos ledger information.

    Returns Promise<LedgerInfo>

    The Aptos Ledger Info, which includes details such as chain ID, epoch, and ledger version.

    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 the ledger information
    const ledgerInfo = await aptos.getLedgerInfo();

    console.log(ledgerInfo);
    }
    runExample().catch(console.error);
  • Retrieve module events based on a specified event type. This function allows you to query for events that are associated with a particular module event type in the Aptos blockchain.

    Parameters

    • args: {
          eventType: `${string}::${string}::${string}`;
          minimumLedgerVersion?: AnyNumber;
          options?: PaginationArgs & OrderByArg<{
              account_address: string;
              creation_number: any;
              data: any;
              event_index: any;
              indexed_type: string;
              sequence_number: any;
              transaction_block_height: any;
              transaction_version: any;
              type: string;
          }>;
      }

      The arguments for retrieving module events.

      • eventType: `${string}::${string}::${string}`

        The event type to filter the results.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: PaginationArgs & OrderByArg<{
            account_address: string;
            creation_number: any;
            data: any;
            event_index: any;
            indexed_type: string;
            sequence_number: any;
            transaction_block_height: any;
            transaction_version: any;
            type: string;
        }>

        Optional pagination and ordering parameters for the event results.

    Returns Promise<{
        account_address: string;
        creation_number: any;
        data: any;
        event_index: any;
        indexed_type: string;
        sequence_number: any;
        transaction_block_height: any;
        transaction_version: any;
        type: string;
    }[]>

    Promise - A promise that resolves to the retrieved events.

    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 module events for a specific event type
    const events = await aptos.getModuleEventsByEventType({
    eventType: "0x1::transaction_fee::FeeStatement", // specify the event type
    minimumLedgerVersion: 1, // optional: specify minimum ledger version if needed
    });

    console.log(events); // log the retrieved events
    }
    runExample().catch(console.error);
  • Fetches a single name from the indexer based on the provided name argument.

    Parameters

    • args: {
          name: string;
      }

      The arguments for retrieving the name.

      • name: string

        A string of the name to retrieve, e.g. "test.aptos.apt" or "test.apt" or "test". Can be inclusive or exclusive of the .apt suffix and can be a subdomain.

    Returns Promise<undefined | {
        domain?: null | string;
        domain_expiration_timestamp?: any;
        expiration_timestamp?: any;
        is_primary?: null | boolean;
        owner_address?: null | string;
        registered_address?: null | string;
        subdomain?: null | string;
        subdomain_expiration_policy?: any;
        token_standard?: null | string;
    }>

    A promise of an ANSName or undefined if the name is not active.

    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 a name from the indexer
    const name = await aptos.getName({ name: "test.aptos" }); // replace with a real name
    console.log(name);
    }
    runExample().catch(console.error);
  • Queries the current number of delegators in a specified pool. Throws an error if the pool is not found.

    Parameters

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

      The parameters for the query.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • poolAddress: AccountAddressInput

        The address of the pool to query.

    Returns Promise<number>

    The number of delegators for the given pool.

    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 number of delegators for a specific pool
    const delegators = await aptos.getNumberOfDelegators({ poolAddress: "0x1" }); // replace with a real pool address
    console.log(`Number of delegators: ${delegators}`);
    }
    runExample().catch(console.error);
  • Retrieves the current number of delegators across all pools.

    Parameters

    • Optionalargs: {
          minimumLedgerVersion?: AnyNumber;
          options?: OrderByArg<{
              num_active_delegator?: any;
              pool_address?: null | string;
          }>;
      }

      Optional parameters for the query.

      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: OrderByArg<{
            num_active_delegator?: any;
            pool_address?: null | string;
        }>

        Optional ordering options for the response.

    Returns Promise<{
        num_active_delegator?: any;
        pool_address?: null | string;
    }[]>

    GetNumberOfDelegatorsForAllPoolsResponse response type containing the number of delegators per pool.

    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 the number of delegators for all pools
    const delegators = await aptos.getNumberOfDelegatorsForAllPools();
    console.log(delegators);
    }
    runExample().catch(console.error);
  • Fetches the object data based on the specified object address.

    Parameters

    • args: {
          minimumLedgerVersion?: AnyNumber;
          objectAddress: AccountAddressInput;
          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;
          }>;
      }
      • OptionalminimumLedgerVersion?: AnyNumber

        Optional minimum ledger version to wait for.

      • objectAddress: AccountAddressInput

        The object address to retrieve data for.

      • 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;
        }>

        Optional configuration options for pagination and ordering.

    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;
    }>

    The object data corresponding to the provided 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 object data by object address
    const objectData = await aptos.getObjectDataByObjectAddress({
    objectAddress: "0x1", // replace with a real object address
    });

    console.log(objectData);
    }
    runExample().catch(console.error);
  • Retrieves the digital assets owned by a specified address.

    Parameters

    • args: {
          minimumLedgerVersion?: AnyNumber;
          options?: 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;
          }>;
          ownerAddress: AccountAddressInput;
      }
      • OptionalminimumLedgerVersion?: AnyNumber

        Optional ledger version to sync up to before querying.

      • Optionaloptions?: 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;
        }>

        Optional pagination and ordering parameters for the response.

      • ownerAddress: AccountAddressInput

        The address of the owner.

    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;
    }[]>

    GetOwnedTokensResponse containing ownership data of the digital assets belonging to the ownerAddress.

    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 the digital assets owned by the specified address
    const digitalAssets = await aptos.getOwnedDigitalAssets({
    ownerAddress: "0x1", // replace with a real account address
    });

    console.log(digitalAssets);
    }
    runExample().catch(console.error);
  • Retrieve the owner address of a specified domain name or subdomain name from the contract.

    Parameters

    • args: {
          name: string;
      }

      The arguments for retrieving the owner address.

      • name: string

        A string representing the name of the domain or subdomain to retrieve the owner address for.

    Returns Promise<undefined | AccountAddress>

    AccountAddress if the name is owned, undefined otherwise.

    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 the owner address of "test.aptos"
    const owner = await aptos.getOwnerAddress({ name: "test.aptos" });
    console.log(owner); // Logs the owner address or undefined if not owned
    }
    runExample().catch(console.error);
  • Fetches the pepper from the Aptos pepper service API.

    Parameters

    • args: {
          derivationPath?: string;
          ephemeralKeyPair: EphemeralKeyPair;
          jwt: string;
      }

      The arguments for fetching the pepper.

      • OptionalderivationPath?: string

        A derivation path used for creating multiple accounts per user via the BIP-44 standard. Defaults to "m/44'/637'/0'/0'/0".

      • ephemeralKeyPair: EphemeralKeyPair

        The EphemeralKeyPair used to generate the nonce in the JWT token.

      • jwt: string

        JWT token.

    Returns Promise<Uint8Array>

    The pepper which is a Uint8Array of length 31.

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

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

    async function runExample() {
    const ephemeralKeyPair = new EphemeralKeyPair(); // create a new ephemeral key pair
    const jwt = "your_jwt_token"; // replace with a real JWT token

    // Fetching the pepper using the provided JWT and ephemeral key pair
    const pepper = await aptos.getPepper({
    jwt,
    ephemeralKeyPair,
    // derivationPath: "m/44'/637'/0'/0'/0" // specify your own if needed
    });

    console.log("Fetched pepper:", pepper);
    }
    runExample().catch(console.error);
  • Retrieve the primary name for an account. An account can have multiple names, but only one primary name, which may not exist.

    Parameters

    Returns Promise<undefined | string>

    A string if the account has a primary name, undefined otherwise.

    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 the primary name for the specified account address
    const name = await aptos.getPrimaryName({ address: "0x1" }); // replace with a real account address
    console.log(name);
    }
    runExample().catch(console.error);
  • Query the processor status for a specific processor type.

    Parameters

    Returns Promise<{
        last_success_version: any;
        last_updated: any;
        processor: string;
    }>

    The status of the specified processor 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 processor status for the account transactions processor
    const status = await aptos.getProcessorStatus("account_transactions_processor");
    console.log(status);
    }
    runExample().catch(console.error);
  • Fetches a proof from the Aptos prover service API.

    Parameters

    • args: {
          ephemeralKeyPair: EphemeralKeyPair;
          jwt: string;
          pepper?: HexInput;
          uidKey?: string;
      }

      The arguments for fetching the proof.

      • ephemeralKeyPair: EphemeralKeyPair

        The EphemeralKeyPair used to generate the nonce in the JWT token.

      • jwt: string

        JWT token.

      • Optionalpepper?: HexInput

        The pepper used for the account. If not provided, it will be fetched from the Aptos pepper service.

      • OptionaluidKey?: string

        A key in the JWT token to use to set the uidVal in the IdCommitment.

    Returns Promise<ZeroKnowledgeSig>

    The proof which is represented by a ZeroKnowledgeSig.

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

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

    async function runExample() {
    const jwt = "your_jwt_token"; // replace with a real JWT token
    const ephemeralKeyPair = new EphemeralKeyPair(); // create a new ephemeral key pair

    // Fetch the proof using the getProof function
    const proof = await aptos.getProof({
    jwt,
    ephemeralKeyPair,
    pepper: await getPepper({}), // fetch the pepper if not provided
    uidKey: "sub", // specify the uid key
    });

    console.log("Fetched proof:", proof);
    }
    runExample().catch(console.error);
  • Returns a signing message for a transaction, allowing a user to sign it using their preferred method before submission to the network.

    Parameters

    Returns Uint8Array

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

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

    async function runExample() {
    const transaction = await aptos.transaction.build.simple({
    sender: "0x1", // replace with a real sender address
    data: {
    function: "0x1::aptos_account::transfer",
    functionArguments: ["0x2", 100], // replace with a real destination address
    },
    });

    const message = await aptos.getSigningMessage({ transaction });
    console.log(message);
    }
    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);
  • Retrieve the target address of a domain or subdomain name, which indicates the address the name points to for use on-chain. Note that the target address can point to addresses that do not own the name.

    Parameters

    • args: {
          name: string;
      }

      The arguments for retrieving the target address.

      • name: string

        A string representing the name, which can be a primary name, a subdomain, or a combination (e.g., "primary", "primary.apt", "secondary.primary", "secondary.primary.apt").

    Returns Promise<undefined | AccountAddress>

    AccountAddress if the name has a target, undefined otherwise.

    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 the target address for the specified domain name
    const targetAddr = await aptos.getTargetAddress({ name: "test.aptos" });

    console.log(targetAddr); // Logs the target address, e.g., 0x123...
    }
    runExample().catch(console.error);
  • Queries on-chain transactions by their transaction hash, returning both pending and committed transactions.

    Parameters

    • args: {
          transactionHash: HexInput;
      }

      The arguments for querying the transaction.

      • transactionHash: HexInput

        The transaction hash should be a hex-encoded bytes string with a 0x prefix.

    Returns Promise<TransactionResponse>

    The transaction from the mempool (pending) or the on-chain (committed) transaction.

    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 a transaction by its hash
    const transaction = await aptos.getTransactionByHash({ transactionHash: "0x123" }); // replace with a real transaction hash

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Queries on-chain transaction by version. This function will not return pending transactions.

    Parameters

    • args: {
          ledgerVersion: AnyNumber;
      }

      The arguments for querying the transaction.

      • ledgerVersion: AnyNumber

        Transaction version is an unsigned 64-bit number.

    Returns Promise<TransactionResponse>

    On-chain transaction. Only on-chain transactions have versions, so this function cannot be used to query pending 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() {
    // Fetching a transaction by its version
    const transaction = await aptos.getTransactionByVersion({ ledgerVersion: 1 }); // replace 1 with a real version
    console.log(transaction);
    }
    runExample().catch(console.error);
  • Queries on-chain transactions, excluding pending transactions. Use this function to retrieve historical transactions from the blockchain.

    Parameters

    • Optionalargs: {
          options?: PaginationArgs;
      }

      Optional parameters for pagination.

    Returns Promise<TransactionResponse[]>

    An array of on-chain 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 with pagination
    const transactions = await aptos.getTransactions({
    options: {
    offset: 0, // Start from the first transaction
    limit: 10, // Limit to 10 results
    },
    });

    console.log(transactions);
    }
    runExample().catch(console.error);
  • Defines if the specified transaction is currently in a pending state. This function helps you determine the status of a transaction using its hash.

    Parameters

    • args: {
          transactionHash: HexInput;
      }

      The arguments for the function.

      • transactionHash: HexInput

        A hash of the transaction in hexadecimal format.

    Returns Promise<boolean>

    true if the transaction is in a pending state and false otherwise.

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

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

    async function runExample() {
    // Check if the transaction is pending using its hash
    const isPendingTransaction = await aptos.isPendingTransaction({ transactionHash: "0x123" }); // replace with a real transaction hash
    console.log("Is the transaction pending?", isPendingTransaction);
    }
    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);
  • Create a transaction to mint a digital asset into the creator's account within an existing collection. This function helps you generate a transaction that can be simulated or submitted to the blockchain for minting a digital asset.

    Parameters

    • args: {
          collection: string;
          creator: Account;
          description: string;
          name: string;
          options?: InputGenerateTransactionOptions;
          propertyKeys?: string[];
          propertyTypes?: (
              | "BOOLEAN"
              | "U8"
              | "U16"
              | "U32"
              | "U64"
              | "U128"
              | "U256"
              | "ADDRESS"
              | "STRING"
              | "ARRAY")[];
          propertyValues?: PropertyValue[];
          uri: string;
      }
      • collection: string

        The name of the collection the digital asset belongs to.

      • creator: Account

        The creator of the collection.

      • description: string

        The description of the digital asset.

      • name: string

        The name of the digital asset.

      • Optionaloptions?: InputGenerateTransactionOptions

        Optional transaction generation options.

      • OptionalpropertyKeys?: string[]

        Optional array of property keys for the digital asset.

      • OptionalpropertyTypes?: (
            | "BOOLEAN"
            | "U8"
            | "U16"
            | "U32"
            | "U64"
            | "U128"
            | "U256"
            | "ADDRESS"
            | "STRING"
            | "ARRAY")[]

        Optional array of property types for the digital asset.

      • OptionalpropertyValues?: PropertyValue[]

        Optional array of property values for the digital asset.

      • uri: string

        The URI to additional info about the digital asset.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Creating a transaction to mint a digital asset
    const transaction = await aptos.mintDigitalAssetTransaction({
    creator: Account.generate(), // replace with a real account
    collection: "MyCollection",
    description: "This is a digital asset.",
    name: "MyDigitalAsset",
    uri: "https://example.com/my-digital-asset",
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Mint a soul bound digital asset into a recipient's account. This function allows you to create a unique digital asset that is bound to a specific account.

    Parameters

    • args: {
          account: Account;
          collection: string;
          description: string;
          name: string;
          options?: InputGenerateTransactionOptions;
          propertyKeys?: string[];
          propertyTypes?: (
              | "BOOLEAN"
              | "U8"
              | "U16"
              | "U32"
              | "U64"
              | "U128"
              | "U256"
              | "ADDRESS"
              | "STRING"
              | "ARRAY")[];
          propertyValues?: PropertyValue[];
          recipient: AccountAddressInput;
          uri: string;
      }

      The arguments for minting the soul bound transaction.

      • account: Account

        The account that mints the digital asset.

      • collection: string

        The collection name that the digital asset belongs to.

      • description: string

        The digital asset description.

      • name: string

        The digital asset name.

      • Optionaloptions?: InputGenerateTransactionOptions

        Additional options for generating the transaction.

      • OptionalpropertyKeys?: string[]

        The property keys for storing on-chain properties.

      • OptionalpropertyTypes?: (
            | "BOOLEAN"
            | "U8"
            | "U16"
            | "U32"
            | "U64"
            | "U128"
            | "U256"
            | "ADDRESS"
            | "STRING"
            | "ARRAY")[]

        The type of property values.

      • OptionalpropertyValues?: PropertyValue[]

        The property values to be stored on-chain.

      • recipient: AccountAddressInput

        The account address where the digital asset will be created.

      • uri: string

        The digital asset URL.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Mint a soul bound digital asset
    const transaction = await aptos.mintSoulBoundTransaction({
    account: Account.generate(), // Replace with a real account
    collection: "collectionName",
    description: "collectionDescription",
    name: "digitalAssetName",
    uri: "digital-asset-uri.com",
    recipient: "0x123" // Replace with a real recipient account address
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Generates a transaction to publish a Move package to the blockchain. This function helps you create a transaction that can be simulated or submitted to the chain for publishing a package.

    To get the metadataBytes and byteCode, can compile using Aptos CLI with command aptos move compile --save-metadata ...,

    https://aptos.dev/tutorials/your-first-dapp/#step-4-publish-a-move-module

    Parameters

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Replace with a real account address
    const account = "0x1";
    const metadataBytes = "0x..."; // replace with real metadata bytes
    const byteCode = "0x..."; // replace with real module bytecode

    const transaction = await aptos.publishPackageTransaction({
    account,
    metadataBytes,
    moduleBytecode: [byteCode],
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Retrieves data from the Aptos Indexer using a GraphQL query. This function allows you to execute complex queries to fetch specific data from the Aptos blockchain.

    Type Parameters

    • T extends {}

    Parameters

    Returns Promise<T>

    The provided T 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() {
    // Querying the Aptos Indexer for ledger information
    const topUserTransactions = await aptos.queryIndexer({
    query: `query MyQuery {
    ledger_infos {
    chain_id
    }
    }`
    });

    console.log(topUserTransactions);
    }
    runExample().catch(console.error);
  • Registers a new name.

    This function allows you to register a domain or subdomain name with specific expiration policies and options.

    Parameters

    Returns Promise<SimpleTransaction>

    SimpleTransaction

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

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

    async function runExample() {
    // Registering a subdomain name assuming def.apt is already registered and belongs to the sender alice.
    const txn = await aptos.registerName({
    sender: "0x1", // replace with a real sender account
    name: "test.aptos.apt",
    expiration: {
    policy: "subdomain:independent",
    expirationDate: Date.now() + 30 * 24 * 60 * 60 * 1000, // expires in 30 days
    },
    });

    console.log("Transaction:", txn);
    }
    runExample().catch(console.error);
  • Remove a digital asset property from the blockchain. This function allows you to delete an existing property associated with a digital asset.

    Parameters

    • args: {
          creator: Account;
          digitalAssetAddress: AccountAddressInput;
          digitalAssetType?: `${string}::${string}::${string}`;
          options?: InputGenerateTransactionOptions;
          propertyKey: string;
          propertyType:
              | "BOOLEAN"
              | "U8"
              | "U16"
              | "U32"
              | "U64"
              | "U128"
              | "U256"
              | "ADDRESS"
              | "STRING"
              | "ARRAY";
          propertyValue: PropertyValue;
      }

      The parameters required to remove the digital asset property.

      • creator: Account

        The account that mints the digital asset.

      • digitalAssetAddress: AccountAddressInput

        The digital asset address.

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

        Optional. The type of the digital asset.

      • Optionaloptions?: InputGenerateTransactionOptions

        Optional. Additional options for generating the transaction.

      • propertyKey: string

        The property key for storing on-chain properties.

      • propertyType:
            | "BOOLEAN"
            | "U8"
            | "U16"
            | "U32"
            | "U64"
            | "U128"
            | "U256"
            | "ADDRESS"
            | "STRING"
            | "ARRAY"

        The type of property value.

      • propertyValue: PropertyValue

        The property value to be stored on-chain.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Remove a digital asset property
    const transaction = await aptos.removeDigitalAssetPropertyTransaction({
    creator: Account.generate(), // replace with a real account
    propertyKey: "newKey",
    propertyType: "BOOLEAN",
    propertyValue: true,
    digitalAssetAddress: "0x123", // replace with a real digital asset address
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Renews a domain name for one year. If a domain name was minted with V1 of the contract, it will automatically be upgraded to V2 via this transaction.

    Parameters

    • args: {
          name: string;
          options?: InputGenerateTransactionOptions;
          sender: Account;
          years?: 1;
      }

      The arguments for renewing the domain.

      • name: string

        A string representing the domain to renew. Subdomains cannot be renewed.

      • Optionaloptions?: InputGenerateTransactionOptions

        Optional transaction options.

      • sender: Account

        The sender account, which must be the domain owner.

      • Optionalyears?: 1

        The number of years to renew the name. Currently, only one year is permitted.

    Returns Promise<SimpleTransaction>

    SimpleTransaction

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

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

    async function runExample() {
    // Renew the domain "test" for one year
    const transaction = await aptos.renewDomain({
    sender: Account.generate(), // replace with a real account
    name: "test"
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Rotate an account's authentication key. After rotation, only the new private key can be used to sign transactions for the account. Note: Only legacy Ed25519 scheme is supported for now. More info: https://aptos.dev/guides/account-management/key-rotation/

    Parameters

    • args: {
          fromAccount: Account;
          toNewPrivateKey: PrivateKey;
      }

      The arguments for rotating the auth key.

      • fromAccount: Account

        The account to rotate the auth key for.

      • toNewPrivateKey: PrivateKey

        The new private key to rotate to.

    Returns Promise<TransactionResponse>

    PendingTransactionResponse

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

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

    async function runExample() {
    // Rotate the authentication key for an account
    const response = await aptos.rotateAuthKey({
    // replace with a real account
    fromAccount: Account.generate(),
    // replace with a real private key
    toNewPrivateKey: new PrivateKey("0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"),
    });

    console.log(response);
    }
    runExample().catch(console.error);
  • Set the digital asset description to provide additional context or information about the asset.

    Parameters

    • args: {
          creator: Account;
          description: string;
          digitalAssetAddress: AccountAddressInput;
          digitalAssetType?: `${string}::${string}::${string}`;
          options?: InputGenerateTransactionOptions;
      }

      The parameters for setting the digital asset description.

      • creator: Account

        The creator account responsible for the digital asset.

      • description: string

        The digital asset description to be set.

      • digitalAssetAddress: AccountAddressInput

        The address of the digital asset.

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

        Optional. The type of the digital asset.

      • Optionaloptions?: InputGenerateTransactionOptions

        Optional. Additional options for generating the transaction.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Set the digital asset description
    const transaction = await aptos.setDigitalAssetDescriptionTransaction({
    creator: Account.generate(), // replace with a real account
    description: "This is a digital asset description.",
    digitalAssetAddress: "0x123", // replace with a real digital asset address
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Set the digital asset name, allowing you to define a name for a specific digital asset on the blockchain.

    Parameters

    • args: {
          creator: Account;
          digitalAssetAddress: AccountAddressInput;
          digitalAssetType?: `${string}::${string}::${string}`;
          name: string;
          options?: InputGenerateTransactionOptions;
      }

      The parameters for setting the digital asset name.

      • creator: Account

        The creator account responsible for the transaction.

      • digitalAssetAddress: AccountAddressInput

        The address of the digital asset.

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

        Optional. The type of the digital asset, represented as a Move struct ID.

      • name: string

        The desired name for the digital asset.

      • Optionaloptions?: InputGenerateTransactionOptions

        Optional. Additional options for generating the transaction.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the blockchain.

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

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

    async function runExample() {
    const creator = Account.generate(); // Generate a new account for the creator
    const digitalAssetAddress = "0x123"; // replace with a real digital asset address

    // Set the digital asset name
    const transaction = await aptos.setDigitalAssetNameTransaction({
    creator: creator,
    name: "digitalAssetName",
    digitalAssetAddress: digitalAssetAddress,
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Set the URI for a digital asset, allowing you to associate a unique identifier with the asset.

    Parameters

    • args: {
          creator: Account;
          digitalAssetAddress: AccountAddressInput;
          digitalAssetType?: `${string}::${string}::${string}`;
          options?: InputGenerateTransactionOptions;
          uri: string;
      }

      The parameters for the transaction.

      • creator: Account

        The creator account initiating the transaction.

      • digitalAssetAddress: AccountAddressInput

        The address of the digital asset.

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

        Optional. The type of the digital asset.

      • Optionaloptions?: InputGenerateTransactionOptions

        Optional. Additional options for generating the transaction.

      • uri: string

        The digital asset URI to be set.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Set the URI for a digital asset
    const transaction = await aptos.setDigitalAssetURITransaction({
    creator: Account.generate(), // Replace with a real creator account
    uri: "digital-asset-uri.com",
    digitalAssetAddress: "0x123", // Replace with a real digital asset address
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Sets the primary name for the sender account, allowing them to designate a single primary name among potentially multiple names. An account may not have a primary name.

    Parameters

    Returns Promise<SimpleTransaction>

    SimpleTransaction

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

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

    async function runExample() {
    // Set the primary name for the sender account
    const sender = Account.generate(); // replace with a real account
    await aptos.setPrimaryName({ sender, name: "test.aptos" });

    const primaryName = await aptos.getPrimaryName({ address: sender.accountAddress });
    console.log("Primary Name:", primaryName); // Should log: "Primary Name: test.aptos"
    }
    runExample().catch(console.error);
  • Sets the target address of a domain or subdomain name, pointing it to a specified address for use on-chain. The target address can be different from the owner of the name.

    Parameters

    Returns Promise<SimpleTransaction>

    SimpleTransaction

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

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

    async function runExample() {
    // Setting the target address for a domain name
    const sender = Account.generate(); // replace with a real account
    const address = "0x1"; // replace with a real account address

    await aptos.setTargetAddress({
    sender: sender,
    name: "test.aptos",
    address: address,
    });

    const targetAddress = await aptos.getTargetAddress({ name: "test.aptos" });
    console.log(targetAddress); // Should log the address set for "test.aptos"
    }
    runExample().catch(console.error);
  • Sign a transaction that can later be submitted to the chain. This function is essential for ensuring the authenticity of the transaction by using the provided account's signing capabilities.

    Parameters

    Returns AccountAuthenticator

    AccountAuthenticator - The authenticator for the signed transaction.

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

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

    async function runExample() {
    const sender = Account.generate(); // Generate a new account for signing
    const transaction = await aptos.transaction.build.simple({
    sender: sender.accountAddress,
    data: {
    function: "0x1::aptos_account::transfer",
    functionArguments: [ "0x1", 100 ], // replace with a real account address and amount
    },
    });

    const signedTransaction = await aptos.transaction.sign({
    signer: sender,
    transaction,
    }); // Sign the transaction

    console.log("Signed Transaction:", signedTransaction);
    }
    runExample().catch(console.error);
  • Sign and submit a single signer transaction as the fee payer to chain given an authenticator by the sender of the transaction.

    Parameters

    Returns Promise<PendingTransactionResponse>

    PendingTransactionResponse

    const transaction = await aptos.transaction.build.simple({sender: alice.accountAddress, feePayer: true ...})
    const senderAuthenticator = alice.signTransactionWithAuthenticator(transaction)
    const pendingTransaction = await aptos.signAndSubmitAsFeePayer({
    senderAuthenticator,
    feePayer: bob,
    transaction,
    })
  • Sign and submit a single signer transaction to the blockchain. This function allows you to execute a transaction after signing it with the specified account.

    Parameters

    Returns Promise<PendingTransactionResponse>

    PendingTransactionResponse

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

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

    async function runExample() {
    const sender = Account.generate(); // Generate a new account for sending the transaction
    const transaction = await aptos.transaction.build.simple({
    sender: sender.accountAddress,
    data: {
    function: "0x1::aptos_account::transfer",
    functionArguments: [ "0x1", 100 ], // replace with a real account address
    },
    });

    // Sign and submit the transaction
    const pendingTransaction = await aptos.signAndSubmitTransaction({
    signer: sender,
    transaction,
    });

    console.log(pendingTransaction);
    }
    runExample().catch(console.error);
  • Sign a transaction as a fee payer that can later be submitted to the chain. This function ensures that the transaction is marked with the fee payer's address, allowing it to be processed correctly.

    Parameters

    • args: {
          signer: Account;
          transaction: AnyRawTransaction;
      }

      The arguments for signing the transaction.

      • signer: Account

        The fee payer signer account.

      • transaction: AnyRawTransaction

        A raw transaction to sign on. This transaction must include a feePayerAddress property.

    Returns AccountAuthenticator

    AccountAuthenticator - The authenticator for the signed transaction.

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

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

    async function runExample() {
    const sender = Account.generate(); // Generate a new account for the fee payer
    const transaction = await aptos.transaction.build.simple({
    // All transactions on Aptos are implemented via smart contracts.
    function: "0x1::aptos_account::transfer",
    functionArguments: [sender.accountAddress, 100],
    feePayerAddress: sender.accountAddress, // Set the fee payer address
    });

    const signedTransaction = await aptos.transaction.signAsFeePayer({
    signer: sender,
    transaction,
    });

    console.log("Signed transaction as fee payer:", signedTransaction);
    }
    runExample().catch(console.error);
  • Generate a transfer coin transaction that can be simulated, signed, and submitted. This function helps you create a transaction to transfer a specified amount of coins from one account to another within the Aptos network.

    Parameters

    Returns Promise<SimpleTransaction>

    SimpleTransaction

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

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

    async function runExample() {
    // Generate a transfer coin transaction
    const transaction = await aptos.transferCoinTransaction({
    sender: "0x1", // replace with a real sender account address
    recipient: "0x2", // replace with a real recipient account address
    amount: 10,
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Transfer ownership of a non-fungible digital asset. This function allows you to transfer a digital asset only if it is not frozen, meaning the ownership transfer is not disabled.

    Parameters

    • args: {
          digitalAssetAddress: AccountAddressInput;
          digitalAssetType?: `${string}::${string}::${string}`;
          options?: InputGenerateTransactionOptions;
          recipient: AccountAddress;
          sender: Account;
      }

      The arguments for transferring the digital asset.

      • digitalAssetAddress: AccountAddressInput

        The address of the digital asset being transferred.

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

        Optional. The type of the digital asset, defaults to "0x4::token::Token".

      • Optionaloptions?: InputGenerateTransactionOptions

        Optional. Additional options for generating the transaction.

      • recipient: AccountAddress

        The account address of the recipient.

      • sender: Account

        The sender account of the current digital asset owner.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Transfer a digital asset
    const transaction = await aptos.transferDigitalAssetTransaction({
    sender: Account.generate(), // replace with a real sender account
    digitalAssetAddress: "0x123", // replace with a real digital asset address
    recipient: "0x456", // replace with a real recipient account address
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Transfer a specified amount of fungible asset from the sender's primary store to the recipient's primary store. This method allows you to transfer any fungible asset, including fungible tokens.

    Parameters

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Transfer fungible asset from sender to recipient
    const transaction = await aptos.transferFungibleAsset({
    sender: Account.generate(), // replace with a real sender account
    fungibleAssetMetadataAddress: "0x123", // replace with a real fungible asset address
    recipient: "0x456", // replace with a real recipient account
    amount: 5
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Unfreeze the ability to transfer a digital asset. This function allows the specified creator account to unfreeze the transfer of a digital asset identified by its address.

    Parameters

    • args: {
          creator: Account;
          digitalAssetAddress: AccountAddressInput;
          digitalAssetType?: `${string}::${string}::${string}`;
          options?: InputGenerateTransactionOptions;
      }

      The parameters for unfreezing the digital asset transfer.

      • creator: Account

        The creator account that is unfreezing the digital asset transfer.

      • digitalAssetAddress: AccountAddressInput

        The address of the digital asset to unfreeze.

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

        Optional. The type of the digital asset being unfrozen.

      • Optionaloptions?: InputGenerateTransactionOptions

        Optional. Additional options for generating the transaction.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Unfreeze the ability to transfer a digital asset
    const transaction = await aptos.unfreezeDigitalAssetTransaferTransaction({
    creator: Account.generate(), // replace with a real creator account
    digitalAssetAddress: "0x123", // replace with a real digital asset address
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Update a digital asset property on-chain.

    Parameters

    • args: {
          creator: Account;
          digitalAssetAddress: AccountAddressInput;
          digitalAssetType?: `${string}::${string}::${string}`;
          options?: InputGenerateTransactionOptions;
          propertyKey: string;
          propertyType:
              | "BOOLEAN"
              | "U8"
              | "U16"
              | "U32"
              | "U64"
              | "U128"
              | "U256"
              | "ADDRESS"
              | "STRING"
              | "ARRAY";
          propertyValue: PropertyValue;
      }

      The parameters for updating the digital asset property.

      • creator: Account

        The account that mints the digital asset.

      • digitalAssetAddress: AccountAddressInput

        The address of the digital asset.

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

        Optional. The type of the digital asset.

      • Optionaloptions?: InputGenerateTransactionOptions

        Optional. Additional options for generating the transaction.

      • propertyKey: string

        The property key for storing on-chain properties.

      • propertyType:
            | "BOOLEAN"
            | "U8"
            | "U16"
            | "U32"
            | "U64"
            | "U128"
            | "U256"
            | "ADDRESS"
            | "STRING"
            | "ARRAY"

        The type of property value.

      • propertyValue: PropertyValue

        The property value to be stored on-chain.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Update a digital asset property
    const transaction = await aptos.updateDigitalAssetPropertyTransaction({
    creator: Account.generate(), // replace with a real account
    propertyKey: "newKey",
    propertyType: "BOOLEAN",
    propertyValue: false,
    digitalAssetAddress: "0x123", // replace with a real digital asset address
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Update a typed digital asset property on-chain. This function allows you to modify the properties of a digital asset, enabling dynamic updates to its attributes.

    Parameters

    • args: {
          creator: Account;
          digitalAssetAddress: AccountAddressInput;
          digitalAssetType?: `${string}::${string}::${string}`;
          options?: InputGenerateTransactionOptions;
          propertyKey: string;
          propertyType:
              | "BOOLEAN"
              | "U8"
              | "U16"
              | "U32"
              | "U64"
              | "U128"
              | "U256"
              | "ADDRESS"
              | "STRING"
              | "ARRAY";
          propertyValue: PropertyValue;
      }

      The arguments for updating the digital asset property.

      • creator: Account

        The account that mints the digital asset.

      • digitalAssetAddress: AccountAddressInput

        The digital asset address.

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

        (Optional) The type of the digital asset.

      • Optionaloptions?: InputGenerateTransactionOptions

        (Optional) Additional options for generating the transaction.

      • propertyKey: string

        The property key for storing on-chain properties.

      • propertyType:
            | "BOOLEAN"
            | "U8"
            | "U16"
            | "U32"
            | "U64"
            | "U128"
            | "U256"
            | "ADDRESS"
            | "STRING"
            | "ARRAY"

        The type of property value.

      • propertyValue: PropertyValue

        The property value to be stored on-chain.

    Returns Promise<SimpleTransaction>

    A SimpleTransaction that can be simulated or submitted to the chain.

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

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

    async function runExample() {
    // Update a typed digital asset property
    const transaction = await aptos.updateDigitalAssetTypedPropertyTransaction({
    creator: Account.generate(), // replace with a real account
    propertyKey: "typedKey",
    propertyType: "U8",
    propertyValue: 2,
    digitalAssetAddress: "0x123", // replace with a real digital asset address
    });

    console.log(transaction);
    }
    runExample().catch(console.error);
  • Waits for a transaction to move past the pending state and provides the transaction response. There are 4 cases.

    1. Transaction is successfully processed and committed to the chain.
      • The function will resolve with the transaction response from the API.
    2. Transaction is rejected for some reason, and is therefore not committed to the blockchain.
      • The function will throw an AptosApiError with an HTTP status code indicating some problem with the request.
    3. Transaction is committed but execution failed, meaning no changes were written to the blockchain state.
      • If checkSuccess is true, the function will throw a FailedTransactionError If checkSuccess is false, the function will resolve with the transaction response where the success field is false.
    4. Transaction does not move past the pending state within args.options.timeoutSecs seconds.
      • The function will throw a WaitForTransactionError

    Parameters

    Returns Promise<CommittedTransactionResponse>

    The transaction on-chain response.

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

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

    async function runExample() {
    // Wait for a transaction to complete using its hash
    const transactionHash = "0x123"; // replace with a real transaction hash
    const transactionResponse = await aptos.waitForTransaction({
    transactionHash,
    options: {
    timeoutSecs: 30, // specify your own timeout if needed
    checkSuccess: true,
    },
    });

    console.log(transactionResponse);
    }
    runExample().catch(console.error);

Properties

account: Account
ans: ANS
coin: Coin
config: AptosConfig

The configuration settings for the Aptos client.

digitalAsset: DigitalAsset
event: Event
faucet: Faucet
fungibleAsset: FungibleAsset
general: General
keyless: Keyless
object: AptosObject
staking: Staking
table: Table
transaction: Transaction