Guides
Deposits & withdrawals

Deposits & withdrawals

A deposit is one L1 Cardano transaction. Withdrawals and delegation are L2 submits. Deposit status streams on the private deposits channel.

Deposit

deposit locks ADA at the head and credits the L2 account behind your Identity, plus a starter basket of testnet tokens. The transaction absorbs in about 5 minutes. In Node you pass a Blockfrost project id; in the browser your CIP-30 wallet signs the transaction.

Deposit
await client.deposit({
amountAda: 15,
blockfrostProjectId: "preview…", // Node; the browser passes a CIP-30 wallet
});

Deposit and delegate to a session key

To trade without exposing your wallet key, deposit from your wallet and delegate trading to a throwaway ephemeralKey. deposit({ delegateTo }) pre-signs an AddDelegatedKey transaction and submits it when the deposit absorbs. Your wallet signs once, at deposit time. After that, the session key signs all trading requests and the wallet is not prompted again.

Deposit + delegate to a session key
import { ephemeralKey } from "@sugar-rush/sdk";
const session = await ephemeralKey(); // a throwaway trading key
localStorage.setItem("sr-session", session.export());
await client.deposit({
amountAda: 15,
blockfrostProjectId: "preview…",
delegateTo: session.accountId, // authorize it to trade for the account
});
// Reconnect as `session` and trade; your wallet key never signs an order.

Watch deposit status

Deposit status
client.on("deposit", (d) => console.log(d.requestId, d.status)); // pending → absorbed
const mine = client.deposits();

Withdraw

withdraw is an L2 submit. The funds settle back to L1, to your account's registered destination.

Withdraw
await client.withdraw({ asset: "VAN", amount: "500" });