Creates a new instance of Coin.
The coin's type string (e.g., "0x2::sui::SUI"). If omitted, methods that require a type will need it passed in manually.
Optionalconfig: CallerConfig
Optional caller configuration (network, access token).
Optionalapi: AftermathApi
An optional AftermathApi instance for coin-specific API calls.
Optional ReadonlyapiAn optional AftermathApi instance for coin-specific API calls.
ReadonlycoinThe coin's type string (e.g., "0x2::sui::SUI"). If omitted, methods that require a type will need it passed in manually.
ReadonlycoinThe Move package name portion of this coin type, e.g. the middle "module" from "0x2::sui::SUI".
Will be empty if no coinType is provided.
ReadonlycoinThe final part of the coin type (the "symbol" or short name) from "0x2::sui::SUI".
Will be empty if no coinType is provided.
The mutable configuration used for subsequent requests.
ReadonlyinnerIf the coin type includes a generic argument (like Coin<0x...>), this is extracted. Else empty.
E.g. "0x5::coin::Coin<0x2::sui::SUI>" => "0x2::sui::SUI".
An optional cached coin metadata object retrieved by getCoinMetadata.
An optional cached price info object retrieved by getPrice.
Static ReadonlyconstantsStatic configuration and defaults for Sui coin types, including the standard SUI coin type, default decimals, and coin object type path.
The canonical coin object type path for Sui's Move module, used in verifying coin objects.
Default decimals for various blockchains or ecosystems. For instance, "sui" => 9, "evm" => 18, etc.
The maximum number of decimals
The default number of decimals for SUI (9).
The canonical coin type string for SUI.
Fetches the metadata (name, symbol, decimals) for this coin type or a provided one, caching it if already requested.
Optionalcoin: string
Optionally override the constructor coinType.
OptionalabortSignal: AbortSignalThe CoinMetadaWithInfo object containing metadata and optional external references.
Fetches metadata for multiple coins at once, returning an array in the same order as the coin types requested.
An object with coins, an array of coin types.
OptionalabortSignal: AbortSignalAn array of CoinMetadaWithInfo with length matching coins.
Retrieves the decimals for multiple coins by calling the Aftermath API for metadata
and extracting the decimals property.
An object containing an array of coin types.
OptionalabortSignal: AbortSignalAn object mapping each coin type to a numeric decimal count.
Retrieves price information (including current price and 24h change) for this coin or a provided coin. If already fetched, it returns the cached data.
Optionalcoin: string
Optionally override the constructor coinType.
OptionalabortSignal: AbortSignalA CoinPriceInfo with price and priceChange24HoursPercentage.
Fetches a list of "verified" coin types from the Aftermath backend. Verified coins typically pass certain safety or liquidity checks.
An array of CoinType strings that are considered verified.
Manually sets the metadata in this Coin instance, storing it in this.metadata.
A CoinMetadaWithInfo object to cache in this instance.
Manually sets the price info in this Coin instance, storing it in this.priceInfo.
A CoinPriceInfo object to cache in this instance.
StaticapiReturns the canonical Aftermath API host for a Sui network.
To target a custom or local host, pass baseUrl in CallerConfig to the
constructor instead.
The Sui network whose host to return.
The network's HTTPS or local HTTP API host.
StaticbalanceScales a raw bigint or numeric amount down by decimals to get a display-friendly float.
For example, 1500000000n with decimals = 9 => 1.5.
The raw on-chain amount as bigint or number.
Number of decimal places for this coin.
The resulting float as an easily readable balance.
StaticbalanceScales a raw amount down by decimals and multiplies by a price in USD,
returning a final USD value. E.g., 1500000000n, decimals=9, price=2.0 => 3.0.
The raw balance as bigint or number.
The coin decimals.
The coin's price in USD.
The computed float in USD.
StaticcoinsGiven a record of coin types => numeric amounts, filters out those with zero or negative amounts, returning only the positive pairs.
A record mapping coin types to numeric amounts.
An object with coins array and amounts array in matching indexes.
StaticcoinsGiven a record of coin types => bigint balances, filters out those with zero or negative balances, returning only the positive pairs.
A record mapping coin types to bigints.
An object with coins array and balances array in matching indexes.
StaticcoinLooks up a coin's symbol if it is known in a provided coinSymbolToCoinTypes
record. For instance, if "SUI" => ["0x2::sui::SUI"], we can find "SUI" from
the coin type "0x2::sui::SUI".
An object with coinType and coinSymbolToCoinTypes.
The coin symbol string or undefined if not found.
StaticcoinIf a KeyType string references a type in angle brackets, extracts the type
inside. Typically for "0x2::coin::Coin<0x2::mycoin::MYCOIN>" -> "0x2::mycoin::MYCOIN".
The key type string to parse.
The substring inside <...> or the original if no brackets found.
StaticdefaultReturns the canonical Sui fullnode URL for a network.
The network whose fullnode URL to return. undefined
defaults to mainnet.
The network's fullnode URL.
StaticfilterFilters a record of coin metadata by a textual query, matching both the coin type and the metadata's name/symbol fields.
An object containing filter and a record of coinMetadatas.
An array of coin types that match the search criteria.
StaticfilterFilters a list of coinTypes by a textual query, matching against both zero-padded
and non-padded forms as well as substring checks.
Contains filter (the search string) and coinTypes.
An array of coin types that match the filter in either raw or zero-padded form.
StaticgetExtracts the Move package name portion from a coin type string. E.g., "0x2::sui::SUI" => "sui".
The coin type string (e.g., "0x2::sui::SUI").
The middle segment of the type or empty string if not parseable.
StaticgetExtracts the final part of the coin type (the symbol or short name). For example, "0x2::sui::SUI" => "SUI".
The coin type string.
The extracted symbol or empty string if not found.
StaticgetExtracts the inner generic argument of a coin type if present. E.g., "0x2::coin::Coin<0x2::sui::SUI>" => "0x2::sui::SUI".
The coin type with a possible <...> suffix.
The inner type or an empty string if not found.
StaticisChecks if an object type string is a Coin<...> object from the standard Sui Move module.
The object type to test.
true if it matches "0x2::coin::Coin<...>", otherwise false.
StaticisChecks if a coin type string corresponds to the canonical SUI coin.
A coin type string.
true if it matches "0x2::sui::SUI", otherwise false.
StaticnormalizeConverts a user-friendly decimal number (e.g., 1.5) to a raw on-chain
integer representation by scaling with the given coin decimals.
For example, 1.5 with decimals = 9 => 1500000000n.
The user-friendly balance as a number.
Number of decimal places for this coin.
A bigint representing the raw on-chain balance.
The
Coinclass provides functionality to manage and inspect coin types, retrieve metadata and prices, and convert balances with respect to coin decimals. It can be instantiated with or without a specificcoinTypefor convenience.Example