near-api-js - v7.0.4
    Preparing search index...

    Class FungibleToken

    Hierarchy

    • BaseFT
      • FungibleToken
    Index

    Constructors

    Properties

    accountId: string
    metadata: FTMetadata

    Methods

    • Get the available balance of an account in indivisible units

      Parameters

      • account: Account

        The account to get the balance of

      Returns Promise<bigint>

    • Register an account to the fungible token contract by paying a storage deposit

      Parameters

      • param: { accountIdToRegister: string; fundingAccount: Account }
        • accountIdToRegister: string

          The AccountID to register

        • fundingAccount: Account

          The Account that will fund the registration

      Returns Promise<any>

    • Converts indivisible units to a decimal number (represented as a string)

      Parameters

      • amount: string | number | bigint

        The amount in indivisible units (e.g. "1234")

      • Optionalprecision: number

        (optional) number of digits shown to the right of the decimal point - rounded down

      Returns string

      The amount as a decimal string (e.g. "1.234")

    • Converts a decimal number to indivisible units

      Parameters

      • amount: string | number

        The amount in decimal format (e.g. "1.234")

      Returns bigint

      The amount in indivisible units (e.g. "1234")

    • Transfer tokens from one account to another

      Parameters

      • param: { amount: string | number | bigint; from: Account; receiverId: string }
        • amount: string | number | bigint

          The amount of tokens to transfer in the smallest unit

        • from: Account

          The Account that will transfer the tokens

        • receiverId: string

          The AccountID that will receive the tokens

      Returns Promise<any>

    • Transfer tokens and call a function on the receiver contract, only works if the receiver implements the ft_on_transfer method

      Parameters

      • param: { amount: bigint; from: Account; msg: string; receiverId: string }

        Transfer call parameters

        • amount: bigint

          The amount of tokens to transfer in the smallest unit

        • from: Account

          The Account that will transfer the tokens

        • msg: string

          The message to send to the ft_on_transfer method

        • receiverId: string

          The AccountID that will receive the tokens

      Returns Promise<any>

    • Unregister an account from the fungible token contract by paying a storage deposit

      Parameters

      • param: { account: Account; force: boolean }
        • account: Account

          The Account to unregister

        • force: boolean

          Whether to remove the account without claiming the storage deposit

      Returns Promise<any>