Skip to content

@lelantos-org/sdk / index / Wallet

Class: Wallet โ€‹

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

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);

Implements โ€‹

Properties โ€‹

address โ€‹

ts
readonly address: ShieldedAddress;

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

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

Implementation of โ€‹

WalletApi.address


cfg โ€‹

ts
readonly cfg: ResolvedWalletConfig;

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

Implementation of โ€‹

ts
SpendContext.cfg

J โ€‹

ts
readonly J: WasmJubjub;

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

Implementation of โ€‹

ts
SpendContext.J

keys โ€‹

ts
readonly keys: SpendingKey;

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

Implementation of โ€‹

WalletApi.keys


P โ€‹

ts
readonly P: Poseidon;

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

Implementation of โ€‹

ts
SpendContext.P

Accessors โ€‹

chain โ€‹

Get Signature โ€‹

ts
get chain(): ChainAdapter;

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

Cast to a concrete adapter type for adapter-specific accessors.

Returns โ€‹

ChainAdapter

Cast to a concrete adapter type for adapter-specific accessors.

Implementation of โ€‹

WalletApi.chain


noteSource โ€‹

Get Signature โ€‹

ts
get noteSource(): NoteSource;

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

Returns โ€‹

NoteSource

Implementation of โ€‹

WalletApi.noteSource


noteStore โ€‹

Get Signature โ€‹

ts
get noteStore(): NoteStore;

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

Returns โ€‹

NoteStore

Implementation of โ€‹

WalletApi.noteStore


nullifierStore โ€‹

Get Signature โ€‹

ts
get nullifierStore(): NullifierStore;

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

Returns โ€‹

NullifierStore

Implementation of โ€‹

ts
SyncContext.nullifierStore

prover โ€‹

Get Signature โ€‹

ts
get prover(): Prover;

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

Returns โ€‹

Prover

Implementation of โ€‹

WalletApi.prover


scanner โ€‹

Get Signature โ€‹

ts
get scanner(): Scanner;

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

Returns โ€‹

Scanner

Implementation of โ€‹

WalletApi.scanner


selector โ€‹

Get Signature โ€‹

ts
get selector(): CoinSelector;

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

Returns โ€‹

CoinSelector

Implementation of โ€‹

WalletApi.selector


submitter โ€‹

Get Signature โ€‹

ts
get submitter(): Submitter;

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

Returns โ€‹

Submitter

Implementation of โ€‹

WalletApi.submitter


treeStore โ€‹

Get Signature โ€‹

ts
get treeStore(): TreeStore;

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

Returns โ€‹

TreeStore

Implementation of โ€‹

ts
SpendContext.treeStore

Methods โ€‹

asset() โ€‹

ts
asset(ref, opts?): Promise<AssetInfo>;

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

Registry entry for id plus ERC-20 symbol/decimals when the adapter exposes them. Cached for the wallet's lifetime โ€” asset entries are immutable apart from the disabled flag; { refresh: true } re-reads it.

Parameters โ€‹

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

Returns โ€‹

Promise<AssetInfo>

Implementation of โ€‹

WalletApi.asset


assets() โ€‹

ts
assets(): Promise<AssetInfo[]>;

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

Every asset this chain has registered, lowest id first.

Returns โ€‹

Promise<AssetInfo[]>

Implementation of โ€‹

WalletApi.assets


awaitCommitments() โ€‹

ts
awaitCommitments(cms, opts?): Promise<AwaitCommitmentsResult>;

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

Poll sync() until every commitment in cms is stored locally.

Reports whether they arrived โ€” see AwaitCommitmentsResult. Does not throw on timeout by default: this runs after a successful broadcast, so a lagging indexer is not a failed transaction.

Parameters โ€‹

ParameterType
cmsstring[]
opts?AwaitCommitmentsOpts

Returns โ€‹

Promise<AwaitCommitmentsResult>

Implementation of โ€‹

WalletApi.awaitCommitments


balance() โ€‹

ts
balance(asset): CircuitAmount;

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

Unspent total for one asset, in circuit units.

Parameters โ€‹

ParameterType
assetAssetIdLike

Returns โ€‹

CircuitAmount

Implementation of โ€‹

WalletApi.balance


balances() โ€‹

ts
balances(): Map<AssetId, CircuitAmount>;

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

Unspent totals keyed by asset id โ€” one pass for a multi-asset view.

Returns โ€‹

Map<AssetId, CircuitAmount>

Implementation of โ€‹

WalletApi.balances


cancelDeposit() โ€‹

ts
cancelDeposit(id, inputs): Promise<{
  txHash: Hex32;
}>;

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

Cancel an escrowed deposit. Permissionless after cancelDelay blocks. Caller supplies the DepositEscrowed event payload for the on-chain digest check.

Parameters โ€‹

ParameterType
idbigint
inputsCancelDepositInputs

Returns โ€‹

Promise<{ txHash: Hex32; }>

Implementation of โ€‹

WalletApi.cancelDeposit


compact() โ€‹

ts
compact(): Promise<{
  removed: number;
}>;

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

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; }>

Implementation of โ€‹

WalletApi.compact


create() โ€‹

ts
static create(source, cfg): Promise<Wallet>;

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

Build from any key source. Wires defaults for omitted pluggables. Collects every config problem into WalletConfigError.missing.

Parameters โ€‹

ParameterType
sourceKeySource
cfgWalletConfig

Returns โ€‹

Promise<Wallet>


deposit() โ€‹

ts
deposit(args): Promise<DepositResult>;

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

Shield ERC-20 into the MASP via Permit2 escrow. Funds sit in escrow until the relayer flushes a batch (or cancelDeposit after cancelDelay blocks). For native ETH set asEth: true.

Parameters โ€‹

ParameterType
argsDepositOptions

Returns โ€‹

Promise<DepositResult>

Implementation of โ€‹

WalletApi.deposit


dispose() โ€‹

ts
dispose(): Promise<void>;

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

Release everything this wallet holds: scanner workers and, if one was built, the prover's.

WorkerPoolScanner spawns 2โ€“8 workers per wallet, each with its own wasm heap, and Scanner.dispose existed with no caller โ€” so an app that rebuilds its wallet on an account or network switch leaked a whole pool every time.

Idempotent, and safe on a wallet that never synced or proved. The wallet must not be used afterwards.

Returns โ€‹

Promise<void>

Implementation of โ€‹

WalletApi.dispose


feeBps() โ€‹

ts
feeBps(): Promise<bigint>;

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

SpendContext โ€” config override, else the chain's fee.

Returns โ€‹

Promise<bigint>

Implementation of โ€‹

ts
SpendContext.feeBps

markPendingSpend() โ€‹

ts
markPendingSpend(noteIds): Promise<void>;

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

Reserve notes against a spend whose outcome is unknown, so the selector stops offering them until reconciliation or expiry settles it.

Called automatically when a submit fails without an answer; see submitSpend and StoredNote.pendingSpendAt.

Parameters โ€‹

ParameterType
noteIdsstring[]

Returns โ€‹

Promise<void>

Implementation of โ€‹

ts
SpendContext.markPendingSpend

markSpent() โ€‹

ts
markSpent(noteIds): Promise<void>;

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

Called automatically by transfer / withdraw; exposed for alternative spend flows.

Parameters โ€‹

ParameterType
noteIdsstring[]

Returns โ€‹

Promise<void>

Implementation of โ€‹

WalletApi.markSpent


notes() โ€‹

ts
notes(filter?): WalletNote[];

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

Omit a field to stop filtering on it; notes() returns everything.

Parameters โ€‹

ParameterType
filter?NotesFilter

Returns โ€‹

WalletNote[]

Implementation of โ€‹

WalletApi.notes


quoteFee() โ€‹

ts
quoteFee(args): Promise<FeeQuoteResult>;

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

What relaying kind costs and what it may be paid in, before building anything.

options[].affordable is checked against this wallet's own balances, so a UI can offer only the assets the holder can actually pay with.

Parameters โ€‹

ParameterType
argsQuoteFeeArgs

Returns โ€‹

Promise<FeeQuoteResult>

Implementation of โ€‹

WalletApi.quoteFee


refresh() โ€‹

ts
refresh(): Promise<void>;

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

Reload in-memory cache from NoteStore after external mutation.

Returns โ€‹

Promise<void>

Implementation of โ€‹

WalletApi.refresh


resolveAsset() โ€‹

ts
resolveAsset(ref): Promise<AssetInfo>;

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

SpendContext โ€” id, token address or symbol to a registry entry.

Parameters โ€‹

ParameterType
refAssetRef

Returns โ€‹

Promise<AssetInfo>

Implementation of โ€‹

ts
SpendContext.resolveAsset

selectNotes() โ€‹

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

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

Parameters โ€‹

ParameterType
assetAssetId
targetCircuitAmount
opts?SelectOpts

Returns โ€‹

SelectionResult

Implementation of โ€‹

WalletApi.selectNotes


spendableMax() โ€‹

ts
spendableMax(asset, opts?): Promise<SpendableMax>;

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

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>

Implementation of โ€‹

WalletApi.spendableMax


storedNotes() โ€‹

ts
storedNotes(): readonly StoredNote[];

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

SpendContext โ€” the raw stored-note list.

Returns โ€‹

readonly StoredNote[]

Implementation of โ€‹

ts
SpendContext.storedNotes

swap() โ€‹

ts
swap(args): Promise<SwapResult>;

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

Atomic shielded swap. Leg-1 transact_2x2 unshields to SwapWrapper; leg-2 deposit request re-shields the B note. Bundled via submitter.submitSwap. args.amount is gross publicOut in circuit units of assetIn; MASP skims feeBps before transferring.

Parameters โ€‹

ParameterType
argsSwapOptions

Returns โ€‹

Promise<SwapResult>

Implementation of โ€‹

WalletApi.swap


sync() โ€‹

ts
sync(opts?): Promise<SyncResult>;

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

Pull encrypted notes, the Merkle tree, and the spent set in parallel, then reconcile which local notes are now spent. Convenience wrapper around syncNotes + syncTree + syncNullifiers.

Parameters โ€‹

ParameterType
opts?SyncOpts

Returns โ€‹

Promise<SyncResult>

Implementation of โ€‹

WalletApi.sync


syncNotes() โ€‹

ts
syncNotes(opts?): Promise<SyncResult>;

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

Pull encrypted notes, trial-decrypt with ivk + dk, persist hits.

Pages the feed to exhaustion, resuming from the cursor on NotesFile.cursor, so a caught-up wallet fetches nothing. Idempotent: re-scanning a note already stored is dropped by cm. Does not sync the tree. limit is the page size, not a ceiling on notes fetched.

Parameters โ€‹

ParameterType
opts?SyncOpts

Returns โ€‹

Promise<SyncResult>

Implementation of โ€‹

WalletApi.syncNotes


syncNullifiers() โ€‹

ts
syncNullifiers(): Promise<void>;

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

Fetch new spent-nullifier chunks into the local set. Idempotent โ€” resumes from its own cursor. reconcileSpentOnChain reads this set, so a stale mirror only ever under-reports spends; it never marks a live note spent.

Returns โ€‹

Promise<void>


syncTree() โ€‹

ts
syncTree(): Promise<void>;

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

Fetch new Merkle commitment chunks and rebuild the local tree. Idempotent โ€” resumes from syncedCount cursor. Does not scan notes.

Returns โ€‹

Promise<void>

Implementation of โ€‹

WalletApi.syncTree


transfer() โ€‹

ts
transfer(args): Promise<TransferResult>;

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

Shielded transfer: 1-2 notes โ†’ send-note + change-note โ†’ submit โ†’ mark spent. Throws InsufficientCoverError on no 1/2-note cover.

Parameters โ€‹

ParameterType
argsTransferOptions

Returns โ€‹

Promise<TransferResult>

Implementation of โ€‹

WalletApi.transfer


withdraw() โ€‹

ts
withdraw(args): Promise<WithdrawResult>;

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

Unshield ERC20 to args.to. Throws InsufficientCoverError on no cover.

Parameters โ€‹

ParameterType
argsWithdrawOptions

Returns โ€‹

Promise<WithdrawResult>

Implementation of โ€‹

WalletApi.withdraw


withdrawEth() โ€‹

ts
withdrawEth(args): Promise<WithdrawResult>;

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

Unshield to raw ETH via NativeAdapter.withdrawNative, which unwraps.

Parameters โ€‹

ParameterType
argsWithdrawEthOptions

Returns โ€‹

Promise<WithdrawResult>

Implementation of โ€‹

WalletApi.withdrawEth

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