A representation of an Asset.

Constructors

  • Private constructor for the Asset class.

    Parameters

    • networkId: string

      The network ID.

    • assetId: string

      The asset ID.

    • contractAddress: string

      The address ID.

    • decimals: number

      The number of decimals.

    Returns Asset

Properties

assetId: string
contractAddress: string
decimals: number
networkId: string

Methods

  • Converts the amount of the Asset from atomic to whole units.

    Parameters

    • atomicAmount: Decimal

      The atomic amount to convert to whole units.

    Returns Decimal

    The amount in atomic units

  • Returns the primary denomination for the Asset.

    Returns string

    The primary denomination for the Asset.

  • Converts the amount of the Asset from whole to atomic units.

    Parameters

    • wholeAmount: Decimal

      The whole amount to convert to atomic units.

    Returns bigint

    The amount in atomic units

  • Returns a string representation of the Asset.

    Returns string

    a string representation of the Asset

  • Fetches the Asset with the provided Asset ID.

    Parameters

    • networkId: string

      The network ID.

    • assetId: string

      The asset ID.

    Returns Promise<Asset>

    The Asset Class.

    Throws

    If the Asset cannot be fetched.

  • Creates an Asset from an Asset Model.

    Parameters

    • model: Asset

      The Asset Model.

    • Optional assetId: string

      The Asset ID.

    Returns Asset

    The Asset Class.

    Throws

    If the Asset Model is invalid.

  • Returns the primary denomination for the provided Asset ID. For gwei and wei the primary denomination is eth. For all other assets, the primary denomination is the same asset ID.

    Parameters

    • assetId: string

      The Asset ID.

    Returns string

    The primary denomination for the Asset ID.