@aptos-labs/ts-sdk - v5.1.4
    Preparing search index...

    Class FungibleAsset

    A class for querying and managing fungible asset-related operations on the Aptos blockchain.

    Hierarchy (View Summary)

    Index

    FungibleAsset

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

      Parameters

      • config: AptosConfig

        The configuration settings for connecting to the Aptos network.

      Returns FungibleAsset

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

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

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

      console.log("Aptos client initialized:", aptos);
      }
      runExample().catch(console.error);
    • Queries all fungible asset balances.

      Parameters

      Returns Promise<
          {
              amount: any;
              asset_type: string;
              is_frozen: boolean;
              is_primary: boolean;
              last_transaction_timestamp?: any;
              last_transaction_version?: any;
              owner_address: string;
              storage_id: 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 current fungible asset balances
      const fungibleAssetBalances = await aptos.getCurrentFungibleAssetBalances();

      console.log(fungibleAssetBalances);
      }
      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);
    • 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);
    • Transfer a specified amount of fungible asset from the sender's any (primary or secondary) fungible store to any (primary or secondary) fungible 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.

      Error if:

      • The sender account is invalid
      • The store addresses are invalid
      • The amount is negative or zero
      • The transaction fails to generate
      import { Aptos, AptosConfig, Network, Account } from "@aptos-labs/ts-sdk";

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

      async function transferAssets() {
      // Transfer 100 units of the asset from senderStore to recipientStore
      const transaction = await aptos.transferFungibleAssetBetweenStores({
      sender: Account.generate(), // replace with a real sender account
      fromStore: "0x123", // replace with a real fungible store address
      toStore: "0x456", // replace with a real fungible store address
      amount: 100
      });

      console.log(transaction);
      }

      transferAssets().catch(console.error);

    Properties

    config: AptosConfig

    The configuration settings for connecting to the Aptos network.