Retrieve coin

Example Code

const coins = await coinProvider.getCoins({
  coinTypes: ['0x2::sui::SUI'],
});

Example Response

It will return Coin[] instances, with Coinintance you can do a lot of thing not just JSON

Key Properties:

  1. coinType: Identifies the coin type.

  2. decimals: The number of decimal places (e.g., 18 decimals for Ether).

  3. symbol, name, description, iconUrl: Optional information about the coin, like its name, symbol, description, and an icon URL.

  4. derivedPriceInUSD, derivedSUI: Optional values for the coinโ€™s price in USD or SUI.

  5. isVerified: Marks if the coin is verified.

Main Methods:

  1. sortsBefore: Compares this coin with another to see which comes first in a sorted list.

  2. wrapped: Returns the coin itself (currently does nothing extra).

  3. equals: Checks if this coin is the same as another by comparing their coinType.

  4. fetchAllOwnedCoins: Retrieves all the coins owned by an address.

  5. take: Transfers a specified amount of coins to a transaction, making sure the balance is enough and handling the SUI-specific coins appropriately.

Last updated

Was this helpful?