Withdrawing Tokens
When to Use
async withdraw(
token: Token,
amount: bigint,
quotedFees: QuotedFees,
withdrawalAddress: Address,
pocketMoney: bigint
): Promise<`0x${string}`>What It Does
Example
...
import { initializeShielderClient } from "./shielder";
import { nativeToken } from "@cardinal-cryptography/shielder-sdk";
const amountToWithdraw = 500_000_000_000_000n; // 0.0005 ETH
const withdrawalAddress = "0x..." as const;
(async () => {
const shielder = await initializeShielderClient();
const token = nativeToken();
// Sync to ensure up-to-date state
await shielder.syncShielder();
// Get fee quote from relayer for this withdrawal
const quotedFees = await shielder.getWithdrawFees(token, 0n); // pocketMoney = 0n for native
// Withdraw through relayer
const txHash = await shielder.withdraw(
token,
amountToWithdraw,
quotedFees,
withdrawalAddress,
0n // pocketMoney, usually 0 for native token
);
console.log("Withdraw tx hash:", txHash);
})();
...Pocket Money (for ERC-20s only)
Tips
Last updated

