Skip to content

@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:

ts
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 โ€‹

ts
readonly address: ShieldedAddress;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:39

This wallet's shielded lelantos1โ€ฆ address (bech32m).


chain โ€‹

ts
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 โ€‹

ts
readonly keys: SpendingKey;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:40


noteSource โ€‹

ts
readonly noteSource: NoteSource;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:44


noteStore โ€‹

ts
readonly noteStore: NoteStore;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:41


prover โ€‹

ts
readonly prover: Prover;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:46


scanner โ€‹

ts
readonly scanner: Scanner;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:47


selector โ€‹

ts
readonly selector: CoinSelector;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:48


submitter โ€‹

ts
readonly submitter: Submitter;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:45

Methods โ€‹

asset() โ€‹

ts
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 โ€‹

ParameterType
refAssetRef
opts?{ refresh?: boolean; }
opts.refresh?boolean

Returns โ€‹

Promise<AssetInfo>


assets() โ€‹

ts
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() โ€‹

ts
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 โ€‹

ParameterType
cmsHex32[]
opts?AwaitCommitmentsOpts

Returns โ€‹

Promise<AwaitCommitmentsResult>


balance() โ€‹

ts
balance(asset): CircuitAmount;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:68

Unspent total for one asset, in circuit units.

Parameters โ€‹

ParameterType
assetAssetIdLike

Returns โ€‹

CircuitAmount


balances() โ€‹

ts
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() โ€‹

ts
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 โ€‹

ParameterType
idbigint
inputsCancelDepositInputs

Returns โ€‹

Promise<{ txHash: Hex32; }>


compact() โ€‹

ts
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() โ€‹

ts
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 โ€‹

ParameterType
argsDepositOptions

Returns โ€‹

Promise<DepositResult>


dispose() โ€‹

ts
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() โ€‹

ts
markSpent(noteIds): Promise<void>;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:122

Parameters โ€‹

ParameterType
noteIdsstring[]

Returns โ€‹

Promise<void>


notes() โ€‹

ts
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 โ€‹

ParameterType
filter?NotesFilter

Returns โ€‹

WalletNote[]


quoteFee() โ€‹

ts
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 โ€‹

ParameterType
argsQuoteFeeArgs

Returns โ€‹

Promise<FeeQuoteResult>


refresh() โ€‹

ts
refresh(): Promise<void>;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:57

Returns โ€‹

Promise<void>


selectNotes() โ€‹

ts
selectNotes(
   asset, 
   target, 
   opts?
): SelectionResult;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:102

Parameters โ€‹

ParameterType
assetAssetId
targetCircuitAmount
opts?SelectOpts

Returns โ€‹

SelectionResult


spendableMax() โ€‹

ts
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 โ€‹

ParameterType
assetAssetId
opts?SelectOpts

Returns โ€‹

Promise<SpendableMax>


swap() โ€‹

ts
swap(args): Promise<SwapResult>;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:112

Atomic shielded swap; legs bundled via submitter.submitSwap.

Parameters โ€‹

ParameterType
argsSwapOptions

Returns โ€‹

Promise<SwapResult>


sync() โ€‹

ts
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 โ€‹

ParameterType
opts?SyncOpts

Returns โ€‹

Promise<SyncResult>


syncNotes() โ€‹

ts
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 โ€‹

ParameterType
opts?SyncOpts

Returns โ€‹

Promise<SyncResult>


syncTree() โ€‹

ts
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() โ€‹

ts
transfer(args): Promise<TransferResult>;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:106

Shielded transfer to another lelantos1โ€ฆ address.

Parameters โ€‹

ParameterType
argsTransferOptions

Returns โ€‹

Promise<TransferResult>


withdraw() โ€‹

ts
withdraw(args): Promise<WithdrawResult>;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:108

Unshield to an ERC-20 recipient.

Parameters โ€‹

ParameterType
argsWithdrawOptions

Returns โ€‹

Promise<WithdrawResult>


withdrawEth() โ€‹

ts
withdrawEth(args): Promise<WithdrawResult>;

Defined in: @lelantos-org/sdk/dist/wallet/api.d.ts:110

Unshield to raw ETH via the WETH bridge.

Parameters โ€‹

ParameterType
argsWithdrawEthOptions

Returns โ€‹

Promise<WithdrawResult>

Lelantosno cookies ๐Ÿช ยท no tracking ๐Ÿ‘๏ธ ยท no accounts ๐Ÿ‘คwalletexplorer4536080GitHub