Creates a price service with optional API host and authentication settings.
Optionalconfig: CallerConfig
Optional HTTP caller configuration. Set network or
baseUrl to select the API host. baseUrl takes precedence over network.
Set accessToken to send a bearer token with each request.
Fetches the current USD price for one coin type.
This method fetches the coin's price information and returns only its price
field. The returned number is USD per whole coin unit, not an on-chain
smallest-unit amount.
Pass abortSignal to cancel the underlying HTTP request.
The price request.
The Sui coin type to query, such as
"0x2::sui::SUI".
OptionalabortSignal: AbortSignal
Optional caller-owned signal forwarded to fetch.
The current price in USD per whole coin unit.
Fetches price information for one coin type.
This method sends a one-element coins array to the multi-coin price
endpoint and returns the first value in the response record. A successful
response normally contains the requested coin's entry.
Pass abortSignal to cancel the underlying HTTP request. A caller abort is
reported as an AftermathTransportError with kind: "abort", unless the
abort reason identifies a timeout.
The price request.
The Sui coin type to query, such as
"0x2::sui::SUI".
OptionalabortSignal: AbortSignal
Optional caller-owned signal forwarded to fetch.
The coin's price in USD per whole coin and its 24-hour percentage change.
Fetches current USD prices for multiple coin types.
This method fetches detailed price information and projects each response
entry to its price field. The returned record keeps the response coin-type
keys and contains USD per whole coin unit.
Pass abortSignal to cancel the underlying HTTP request.
The price request.
The Sui coin types to query, such as
["0x2::sui::SUI"].
OptionalabortSignal: AbortSignal
Optional caller-owned signal forwarded to fetch.
A record mapping response coin types to current USD prices per whole coin unit.
Fetches price information for multiple coin types.
This method sends inputs as a JSON POST body to the price-info endpoint,
which defaults to /api/price-info. It returns the response record keyed by
coin type. Each record value contains a USD price per whole coin and the
service's 24-hour percentage change.
Pass abortSignal to cancel the underlying HTTP request.
The price request.
The Sui coin types to query, such as
["0x2::sui::SUI"].
OptionalabortSignal: AbortSignal
Optional caller-owned signal forwarded to fetch.
A record mapping the response coin types to their price information.
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.
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.
Fetches current USD price information for Sui coin types.
Each method sends a JSON POST request to the configured Aftermath
price-infoendpoint, which defaults to/api/price-info. Price values are JavaScriptnumbers expressed in USD per whole coin unit. The response also includes the service's 24-hour percentage change. Pass anAbortSignalto a method when the request must be cancellable. Coin types are passed to the endpoint without local validation. If neithernetworknorbaseUrlis configured, a request rejects with anAftermathTransportErrorwhosekindis"network".HTTP failures expose their status and optional retry delay on
AftermathTransportError. Network, timeout, cancellation, and response decoding failures use the same error type with a correspondingkind.