import { StarkZap, PrivySigner, OnboardStrategy, accountPresets } from "starkzap";
const sdk = new StarkZap({ network: "sepolia" });
const accessToken = await privy.getAccessToken();
// Option 1: Using onboard API (recommended)
const onboard = await sdk.onboard({
strategy: OnboardStrategy.Privy,
accountPreset: accountPresets.argentXV050,
privy: {
resolve: async () => {
// Get Privy signer context (walletId + publicKey) from your backend
const walletRes = await fetch("https://your-api.example/api/wallet/starknet", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
});
const walletData = await walletRes.json();
return {
walletId: walletData.wallet.id,
publicKey: walletData.wallet.publicKey,
serverUrl: "https://your-api.example/api/wallet/sign",
};
},
},
deploy: "if_needed",
});
const wallet = onboard.wallet;
// Option 2: Using PrivySigner directly (reuse accessToken)
const walletRes = await fetch("https://your-api.example/api/wallet/starknet", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
});
const { wallet: privyWallet } = await walletRes.json();
const signer = new PrivySigner({
walletId: privyWallet.id,
publicKey: privyWallet.publicKey,
serverUrl: "https://your-api.example/api/wallet/sign",
});
const walletFromSigner = await sdk.connectWallet({
account: { signer, accountClass: accountPresets.argentXV050 },
});