Skip to main content

Installation

pnpm add smart-account-kit

Initialize the SDK

import { SmartAccountKit, IndexedDBStorage } from 'smart-account-kit';

const kit = new SmartAccountKit({
  rpcUrl: 'https://soroban-testnet.stellar.org',
  networkPassphrase: 'Test SDF Network ; September 2015',
  accountWasmHash: 'YOUR_ACCOUNT_WASM_HASH',
  webauthnVerifierAddress: 'YOUR_WEBAUTHN_VERIFIER_ADDRESS',
  storage: new IndexedDBStorage(),
});
Testnet contract addresses (WASM hashes, verifier addresses, policy addresses) are available in the demo .env.example.

Create a Wallet

Prompt the user to register a passkey and deploy a new smart account:
const { contractId, credentialId } = await kit.createWallet('My App', 'user@example.com', {
  autoSubmit: true,  // Deploy immediately
  autoFund: true,    // Fund via Friendbot (testnet only)
  nativeTokenContract: 'CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC',
});

console.log('Wallet deployed at:', contractId);

Connect to an Existing Wallet

On subsequent page loads, silently restore a session or prompt for passkey selection:
// Silent restore (no UI prompt)
const result = await kit.connectWallet();

if (!result) {
  // No stored session - show your connect button
  showConnectButton();
}

// User clicks "Connect" - prompt passkey selection
await kit.connectWallet({ prompt: true });

Sign and Submit a Transaction

import { TransactionBuilder, Networks, Operation, Asset } from '@stellar/stellar-sdk';

// Build your transaction
const tx = new TransactionBuilder(account, { fee: BASE_FEE, networkPassphrase: Networks.TESTNET })
  .addOperation(Operation.payment({ destination, asset: Asset.native(), amount: '10' }))
  .setTimeout(30)
  .build();

// Sign and submit via the smart account
const result = await kit.signAndSubmit(tx);

if (result.success) {
  console.log('Submitted:', result.hash);
}

Transfer Tokens

For simple token transfers, use the transfer shortcut:
await kit.transfer(
  'CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC', // token contract
  'GRECIPIENT...',  // recipient address
  100               // amount
);

Disconnect

await kit.disconnect(); // Clears session; passkey and contract remain intact

Full Example

import { SmartAccountKit, IndexedDBStorage } from 'smart-account-kit';

const kit = new SmartAccountKit({
  rpcUrl: 'https://soroban-testnet.stellar.org',
  networkPassphrase: 'Test SDF Network ; September 2015',
  accountWasmHash: process.env.ACCOUNT_WASM_HASH!,
  webauthnVerifierAddress: process.env.WEBAUTHN_VERIFIER!,
  storage: new IndexedDBStorage(),
});

// On page load
const session = await kit.connectWallet();
if (session) {
  console.log('Restored session for:', session.contractId);
} else {
  // Show UI to create or connect wallet
}

// Create wallet button
async function handleCreate() {
  const { contractId } = await kit.createWallet('My App', 'user@example.com', {
    autoSubmit: true,
    autoFund: true,
  });
  console.log('Created:', contractId);
}

// Connect wallet button
async function handleConnect() {
  await kit.connectWallet({ prompt: true });
}

Next Steps

Configuration

Full list of SDK initialization options.

SmartAccountKit API

Explore all available methods.

Storage Adapters

Choose the right storage backend for your app.

Multi-Sig

Set up threshold and weighted multi-signer flows.