Withdraw
The two functions a withdrawal uses, its context and the withdrawal itself.
A withdrawal runs in a context made from the session. Withdraw walks through the flow.
createWithdrawalContext
Create one from the session before a withdrawal. It picks the pool the withdrawal spends from.
function createWithdrawalContext(
session: NimbusSession,
options?: NimbusContextOptions,
): Promise<WithdrawalContext>;Types used: NimbusSession, NimbusContextOptions, WithdrawalContext
Example
import { } from "@umbra/nimbus-solana-web";
import type { NimbusSession } from "@umbra/nimbus-solana-web";
declare const : NimbusSession;
const = await ();Parameters
Prop
Type
Returns
Promise<WithdrawalContext>
The context.
NimbusSdkError with reason "misconfigured" when an option is out of range or no
pool is open; "service-unavailable" or "unreadable" when the RPC cannot be read.
Creates the context a session withdraws in.
Without options.poolIndex the pools' accounts are read from the RPC once, and the highest open
pool is chosen; the nodes and guardian cluster default to the cluster's preset.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/contexts.ts.
withdraw
Use it to move tokens out of the private balance to any Solana address.
function withdraw(
context: WithdrawalContext,
args: {
readonly mint: Address;
readonly amount: bigint;
readonly recipient: Address;
},
options?: WithdrawOptions,
): Promise<WithdrawalResult>;Types used: WithdrawalContext, WithdrawOptions, WithdrawalResult
Example
import { , } from "@umbra/nimbus-solana-web";
import type { NimbusSession } from "@umbra/nimbus-solana-web";
import type { } from "@solana/kit";
declare const : NimbusSession;
declare const : ;
const = await (await (), {
: 500_000n,
,
: .,
});Parameters
Prop
Type
Returns
Promise<WithdrawalResult>
relayed with the relayer's admission and how following it settled, the payment
known made once the settlement is landed; refused with a SpendRefusal when nothing
was asked of the committee, whose insufficient names the total of every note the session may
spend in the pool, zone and mint; relay-refused when the relayer refused it; unsent when
the note store would not mark it sent; or merge-failed with the merges completed and the
MergeFailureCause of the next.
NimbusSdkError with reason "misconfigured" when an address is not base58, the
mint does not exist, or no prover worker or committee endpoint was configured;
"service-unavailable" or "unreadable" when a service or the RPC cannot answer, and
"unreadable" too when the note store cannot be synced before it starts;
"unauthorized" when a gateway service refuses the session's gateway token or the session has
none; "dependency-nonconforming" when a proving key or the prover breaks its contract;
"account-unregistered" when the context API answers that the session's identity or the
connected wallet has no registration in the pool, before anything is relayed;
NimbusSolanaFlowError when the protocol refuses the withdrawal.
Withdraws amount of mint from the session's notes in the context's pool to recipient's
token account, through the relayer.
First syncs the note store until it is caught up, unless sync: false, and spends the largest
notes the session may spend; the committee endorses, the spend is proved, and the relayer
submits it. Unless follow: false, it then follows the relay until it lands at commitment
and syncs again, so a relayed result's settlement says it landed and the spent notes are
no longer reserved; with follow: false they stay reserved until a later sync sees them spent. When the largest three notes cannot cover the withdrawal but all of them
can, less the relayer's fee for each merge, it first merges them, each merge a transfer to the
session's own identity that it waits on, syncing the note store, until the merged note is
spendable; onProgress sees each merge's merge-prepared, merge-relayed and merge-settled
before the withdrawal's stages.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/flows.ts.
Last updated