Skip to content

Wallet

The wallet module manages the active session, UTXO queries, and balance calculation.

wallet.open(session)

Opens a wallet session by deriving keys from a seed.

ts
await sdk.wallet.open({
  seed: 'my-secret-seed-phrase',  // At least 16 characters
  accountNonce: 0,                 // Optional hierarchical nonce
});

Parameters

FieldTypeDescription
seedstring | Uint8ArraySecret seed (min 16 chars/bytes)
accountNoncenumber?Optional nonce for multiple accounts from the same seed

This initializes the storage adapter with a walletId derived from the seed.

wallet.close()

Closes the wallet session, releases key material, and flushes storage.

ts
await sdk.wallet.close();

WARNING

JS BigInt values cannot be securely zeroed in memory. The SDK nullifies references, but actual clearing depends on garbage collection.

wallet.getUtxos(query?)

Lists UTXOs for the opened wallet.

ts
const { total, rows } = await sdk.wallet.getUtxos({
  chainId: 11155111,
  assetId: 'my-token',
  includeSpent: false,
  limit: 50,
  offset: 0,
});

Query Parameters

FieldTypeDefaultDescription
chainIdnumber?allFilter by chain
assetIdstring?allFilter by asset
includeSpentboolean?falseInclude spent UTXOs
includeFrozenboolean?falseInclude frozen UTXOs
spentboolean?Override includeSpent
frozenboolean?Override includeFrozen
limitnumber?Page size
offsetnumber?0Page offset
orderBystring?'mkIndex' or 'createdAt'
orderstring?'asc' or 'desc'

Returns

ts
{ total: number; rows: UtxoRecord[] }

wallet.getBalance(query?)

Returns the total balance of spendable (unspent, unfrozen) UTXOs.

ts
const balance = await sdk.wallet.getBalance({
  chainId: 11155111,
  assetId: 'my-token',
});
// balance: bigint (in base units)

Parameters

FieldTypeDescription
chainIdnumber?Filter by chain
assetIdstring?Filter by asset

wallet.markSpent(input)

Marks UTXOs as spent by their nullifiers.

ts
await sdk.wallet.markSpent({
  chainId: 11155111,
  nullifiers: ['0xabc...', '0xdef...'],
});

Typically called after a successful transfer or withdrawal.