Class CoinClient

Class for working with the coin module, such as transferring coins and checking balances.

Hierarchy

  • CoinClient

Constructors

Properties

Methods

Constructors

Properties

aptosClient: AptosClient

Methods

  • Get the balance of the account. By default it checks the balance of 0x1::aptos_coin::AptosCoin, but you can specify a different coin type.

    to use a different type, set the coinType to be the fungible asset type.

    The TS SDK supports fungible assets operations. If you want to use CoinClient with this feature, set the coinType to be the fungible asset metadata address. This option uses the FungibleAssetClient class and queries the fungible asset primary store.

    Returns

    Promise that resolves to the balance as a bigint.

    Parameters

    • account: MaybeHexString | AptosAccount

      Account that you want to get the balance of.

    • Optional extraArgs: {
          coinType?: string;
      }

      Extra args for checking the balance.

      • Optional coinType?: string

    Returns Promise<bigint>

  • Generate, sign, and submit a transaction to the Aptos blockchain API to transfer coins from one account to another. By default it transfers 0x1::aptos_coin::AptosCoin, but you can specify a different coin type with the coinType argument.

    You may set createReceiverIfMissing to true if you want to create the receiver account if it does not exist on chain yet. If you do not set this to true, the transaction will fail if the receiver account does not exist on-chain.

    The TS SDK supports fungible assets operations. If you want to use CoinClient with this feature, set the coinType to be the fungible asset metadata address. This option uses the FungibleAssetClient class and queries the fungible asset primary store.

    Returns

    The hash of the transaction submitted to the API

    Parameters

    • from: AptosAccount

      Account sending the coins

    • to: MaybeHexString | AptosAccount

      Account to receive the coins

    • amount: number | bigint

      Number of coins to transfer

    • Optional extraArgs: OptionalTransactionArgs & {
          coinType?: MaybeHexString;
          createReceiverIfMissing?: boolean;
      }

      Extra args for building the transaction or configuring how the client should submit and wait for the transaction

    Returns Promise<string>

Generated using TypeDoc