SDK PLAYGROUND

INTERACTIVE DEV ENVIRONMENT

PLAYGROUND.TS
typescript
1import { createWallet } from '@stellar-zklogin/sdk';
2 
3// Create wallet instance
4const wallet = createWallet({
5 appName: 'My dApp',
6 network: 'testnet',
7 oauthClients: {
8 google: 'YOUR_GOOGLE_CLIENT_ID'
9 }
10});
11 
12// Step 1: Initialize session
13const { nonce } = await wallet.initializeSession();
14console.log('Session nonce:', nonce);
15 
16// Step 2: Redirect to Google OAuth
17const authUrl = wallet.getAuthorizationUrl('google', redirectUri);
18window.location.href = authUrl;
19 
20// Step 3: After OAuth callback
21await wallet.completeOAuth('google', code, redirectUri);
22 
23// Step 4: Compute wallet address
24await wallet.computeAddress();
25console.log('Wallet:', wallet.getAddress());
26console.log('Balance:', await wallet.getBalance());
CONSOLE.LOG
// StellaRay SDK Playground
// Select a snippet and click RUN to execute
// Or press Ctrl+Enter