Creates a wallet service for a specific Sui address.
The Sui address string whose balances and transaction history
to query. The address is passed to the API as walletAddress and is not
validated or normalized by this constructor.
Optionalconfig: CallerConfig
Optional HTTP caller configuration. Set network or baseUrl
to select the API host. Set accessToken to send a bearer token.
Optionalapi: AftermathApi
Optional low-level AftermathApi instance associated with the
wallet. The current methods use the HTTP API configured by config.
ReadonlyaddressThe Sui address whose balances and history this instance queries.
Optional ReadonlyapiThe optional low-level API provider associated with this wallet.
The mutable configuration used for subsequent requests.
Fetches every coin balance held by this wallet address.
This method sends { walletAddress: address } as a JSON POST body to the
wallet balance endpoint. The response is a record keyed by the coin types
returned by the API. Each value is a bigint in that coin's smallest unit.
This method does not accept an AbortSignal.
A record mapping returned coin types to balances in smallest units.
Fetches one coin balance for this wallet.
This method sends the request { coins: [inputs.coin], walletAddress: address }
to the wallet balance endpoint and returns the first balance in the response.
The balance is a bigint in the coin's smallest unit, such as MIST for SUI.
This method does not accept an AbortSignal.
The balance request.
The Sui coin type to query, such as
"0x2::sui::SUI".
The requested coin balance in its smallest unit.
import { Aftermath } from "aftermath-ts-sdk";
const afSdk = await Aftermath.create({ network: "MAINNET" });
const wallet = afSdk.Wallet(
"0x00000000000000000000000000000000000000000000000000000000000000aa"
);
const suiBalance = await wallet.getBalance({ coin: "0x2::sui::SUI" });
console.log("SUI balance in MIST:", suiBalance.toString());
Fetches balances for the requested coin types.
This method sends { coins, walletAddress: address } as a JSON POST body to
the wallet balance endpoint. The API returns one bigint balance per coin in
the same order as inputs.coins, with each value in the coin's smallest unit.
This method does not accept an AbortSignal.
The balance request.
The Sui coin types to query, such as
["0x2::sui::SUI"].
The balances in the request order. Each balance is a bigint in
the corresponding coin's smallest unit.
import { Aftermath } from "aftermath-ts-sdk";
const afSdk = await Aftermath.create({ network: "MAINNET" });
const wallet = afSdk.Wallet(
"0x00000000000000000000000000000000000000000000000000000000000000aa"
);
const balances = await wallet.getBalances({
coins: ["0x2::sui::SUI"],
});
console.log(balances); // e.g. [1000000000n]
Fetches a page of transactions sent from this wallet address.
This method sends { ...inputs, walletAddress: address } as a JSON POST body
to the wallet transaction-history endpoint. The cursor and limit values
control pagination. The returned nextCursor is null when the response has
no more transactions.
This method does not accept an AbortSignal.
Pagination options.
The transaction page and its next transaction digest, if another page exists.
import { Aftermath } from "aftermath-ts-sdk";
const afSdk = await Aftermath.create({ network: "MAINNET" });
const wallet = afSdk.Wallet(
"0x00000000000000000000000000000000000000000000000000000000000000aa"
);
const txHistory = await wallet.getPastTransactions({ limit: 10 });
console.log(txHistory.transactions, txHistory.nextCursor);
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.
Provides balance and transaction-history queries for one Sui address.
The methods send POST requests through the configured Aftermath HTTP API under
/api/walletby default. TheapiEndpointsetting can change that prefix. Balance values arebigints in each coin's smallest unit. These methods do not accept anAbortSignal, so callers cannot cancel their requests through this class. Coin types are passed to the endpoint without local validation. If neithernetworknorbaseUrlis configured, a request rejects with anAftermathTransportErrorwhosekindis"network".