@lelantos-org/sdk / index / WalletApi
Interface: WalletApi โ
Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:37
The high-level wallet surface. Wallet in ./wallet.ts is the shipped implementation; depend on this interface to keep tests mockable.
Amounts are always in circuit units โ tokenBaseUnits = amount * asset.scale. Use wallet.asset(id) plus parseAmount / formatAmount from ./assets.js to move between circuit units and what a user types.
Typical lifecycle:
const wallet = await connect({ network: "anvil", privateKey, rpcUrl });
await wallet.sync(); // notes + Merkle tree
const weth = requireTokenMeta(await wallet.asset(assetId(1n)));
await wallet.deposit({ asset: weth.id, amount: parseAmount("0.25", weth) });
await wallet.sync();
wallet.balance(weth.id);Properties โ
address โ
readonly address: ShieldedAddress;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:39
This wallet's shielded lelantos1โฆ address (bech32m).
chain โ
readonly chain: ChainAdapter;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:43
Cast to a concrete adapter type for adapter-specific accessors.
keys โ
readonly keys: SpendingKey;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:40
noteSource โ
readonly noteSource: NoteSource;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:44
noteStore โ
readonly noteStore: NoteStore;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:41
prover โ
readonly prover: Prover;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:46
scanner โ
readonly scanner: Scanner;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:47
selector โ
readonly selector: CoinSelector;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:48
submitter โ
readonly submitter: Submitter;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:45
Methods โ
asset() โ
asset(ref, opts?): Promise<AssetInfo>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:75
Registry entry for id plus ERC-20 symbol/decimals when the adapter exposes them. Cached per wallet; pass { refresh: true } to re-read.
Parameters โ
| Parameter | Type |
|---|---|
ref | AssetRef |
opts? | { refresh?: boolean; } |
opts.refresh? | boolean |
Returns โ
Promise<AssetInfo>
assets() โ
assets(): Promise<AssetInfo[]>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:79
Every asset registered on this chain, lowest id first.
Returns โ
Promise<AssetInfo[]>
awaitCommitments() โ
awaitCommitments(cms, opts?): Promise<AwaitCommitmentsResult>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:64
Poll until every commitment in cms is in the local store.
Resolves with a status rather than void, so "the indexer is behind" is distinguishable from "all present".
Parameters โ
| Parameter | Type |
|---|---|
cms | Hex32[] |
opts? | AwaitCommitmentsOpts |
Returns โ
Promise<AwaitCommitmentsResult>
balance() โ
balance(asset): CircuitAmount;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:68
Unspent total for one asset, in circuit units.
Parameters โ
| Parameter | Type |
|---|---|
asset | AssetIdLike |
Returns โ
balances() โ
balances(): Map<AssetId, CircuitAmount>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:70
Unspent totals keyed by asset id โ one pass for a multi-asset view.
Returns โ
Map<AssetId, CircuitAmount>
cancelDeposit() โ
cancelDeposit(id, inputs): Promise<{
txHash: Hex32;
}>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:119
Reclaim an escrowed deposit that the relayer never flushed. Permissionless once chain.cancelDelay() blocks have passed. Supply the DepositEscrowed event payload โ the contract re-derives the digest from it.
Parameters โ
| Parameter | Type |
|---|---|
id | bigint |
inputs | CancelDepositInputs |
Returns โ
Promise<{ txHash: Hex32; }>
compact() โ
compact(): Promise<{
removed: number;
}>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:128
Drop notes flagged spent: true from the underlying store. Returns the number of notes pruned. Balance is unaffected; this only shrinks the on-disk file. Live notes and reconcile state are preserved.
Returns โ
Promise<{ removed: number; }>
deposit() โ
deposit(args): Promise<DepositResult>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:104
Shield ERC-20 (or native ETH via asEth) into the MASP.
Parameters โ
| Parameter | Type |
|---|---|
args | DepositOptions |
Returns โ
Promise<DepositResult>
dispose() โ
dispose(): Promise<void>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:139
Release scanner workers and any prover worker this wallet built.
A WorkerPoolScanner holds 2โ8 workers, each with its own wasm heap, so an app that rebuilds its wallet on an account or network switch must call this or leak a pool per switch. Idempotent; the wallet must not be used afterwards.
Returns โ
Promise<void>
markSpent() โ
markSpent(noteIds): Promise<void>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:122
Parameters โ
| Parameter | Type |
|---|---|
noteIds | string[] |
Returns โ
Promise<void>
notes() โ
notes(filter?): WalletNote[];Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:66
Omit a field to stop filtering on it; notes() returns everything.
Parameters โ
| Parameter | Type |
|---|---|
filter? | NotesFilter |
Returns โ
quoteFee() โ
quoteFee(args): Promise<FeeQuoteResult>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:84
What relaying kind costs and which assets can pay for it, checked against this wallet's balances. Empty when the relayer charges nothing.
Parameters โ
| Parameter | Type |
|---|---|
args | QuoteFeeArgs |
Returns โ
Promise<FeeQuoteResult>
refresh() โ
refresh(): Promise<void>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:57
Returns โ
Promise<void>
selectNotes() โ
selectNotes(
asset,
target,
opts?
): SelectionResult;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:102
Parameters โ
| Parameter | Type |
|---|---|
asset | AssetId |
target | CircuitAmount |
opts? | SelectOpts |
Returns โ
spendableMax() โ
spendableMax(asset, opts?): Promise<SpendableMax>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:101
The largest amount of asset a single spend can cover, and what is holding the rest back.
Not the balance. The selector withholds notes that are reserved by an unconfirmed spend, still in their spend cooldown, or below the dust threshold, and a spend can consume only maxInputs of what remains โ so a "max" built on the balance produces InsufficientCoverError against a figure the caller itself supplied. withheld breaks the difference down by cause so a UI can say which it is.
Takes the same SelectOpts a spend does, so the prediction and the spend cannot be computed under different rules. maxInputs defaults to the circuit's nIn; pass nIn - 1 when a cross-asset fee will need an input slot of its own, and fee for one paid in this same asset.
Parameters โ
| Parameter | Type |
|---|---|
asset | AssetId |
opts? | SelectOpts |
Returns โ
Promise<SpendableMax>
swap() โ
swap(args): Promise<SwapResult>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:112
Atomic shielded swap; legs bundled via submitter.submitSwap.
Parameters โ
| Parameter | Type |
|---|---|
args | SwapOptions |
Returns โ
Promise<SwapResult>
sync() โ
sync(opts?): Promise<SyncResult>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:56
Pull notes and sync the tree in parallel. Convenience wrapper around syncNotes + syncTree.
Parameters โ
| Parameter | Type |
|---|---|
opts? | SyncOpts |
Returns โ
Promise<SyncResult>
syncNotes() โ
syncNotes(opts?): Promise<SyncResult>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:50
Pull encrypted notes only. Sufficient for balance display; does not sync the Merkle tree.
Parameters โ
| Parameter | Type |
|---|---|
opts? | SyncOpts |
Returns โ
Promise<SyncResult>
syncTree() โ
syncTree(): Promise<void>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:52
Fetch new Merkle commitment chunks and rebuild the local tree. Required before spending.
Returns โ
Promise<void>
transfer() โ
transfer(args): Promise<TransferResult>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:106
Shielded transfer to another lelantos1โฆ address.
Parameters โ
| Parameter | Type |
|---|---|
args | TransferOptions |
Returns โ
Promise<TransferResult>
withdraw() โ
withdraw(args): Promise<WithdrawResult>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:108
Unshield to an ERC-20 recipient.
Parameters โ
| Parameter | Type |
|---|---|
args | WithdrawOptions |
Returns โ
Promise<WithdrawResult>
withdrawEth() โ
withdrawEth(args): Promise<WithdrawResult>;Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:110
Unshield to raw ETH via the WETH bridge.
Parameters โ
| Parameter | Type |
|---|---|
args | WithdrawEthOptions |
Returns โ
Promise<WithdrawResult>