Skip to content

Type Definitions

⚠️ Development Version - Subject to Change

These type definitions reflect the current development version and may change before stable release.

TypeScript definitions for LazorKit SDK components, hooks, and configuration.

Quick Reference

import { useWallet, type WalletAccount, type UseWalletReturn } from '@lazorkit/wallet';
 
// Most common types you'll need
type WalletAccount = {
  publicKey: string;        // "base64-encoded-passkey-public-key"  
  smartWallet: string;      // "base58-wallet-address"
  isConnected: boolean;     // Always true when account exists
  isCreated: boolean;       // True if wallet was just created
};
 
// Return types for each method
connect: () => Promise<WalletAccount>
disconnect: () => Promise<void>
signAndSendTransaction: (instruction) => Promise<string>  // tx signature
signTransaction: (instruction) => Promise<Transaction>    // signed tx object
buildSmartWalletTransaction: (payer, instruction) => Promise<{
  createSessionTx: VersionedTransaction,    // unsigned
  executeSessionTx: VersionedTransaction    // unsigned  
}>
createPasskeyOnly: () => Promise<ConnectResponse>
createSmartWalletOnly: (passkey) => Promise<{
  smartWalletAddress: string,
  account: WalletAccount
}>

Core Types

WalletAccount

Connected wallet information.

interface WalletAccount {
  publicKey: string;          // Passkey public key (base64)
  smartWallet: string;        // Smart wallet address (base58)
  isConnected: boolean;       // Always true when account exists
  isCreated: boolean;         // True if wallet was just created
}

UseWalletReturn

Complete hook interface with all properties and methods.

interface UseWalletReturn {
  // State
  account: WalletAccount | null;
  smartWalletPubkey: PublicKey | null;
  isConnected: boolean;
  isConnecting: boolean;
  isSigning: boolean;
  error: Error | null;
 
  // Core Actions
  connect: () => Promise<WalletAccount>;
  disconnect: () => Promise<void>;
  signAndSendTransaction: (instruction: TransactionInstruction) => Promise<string>;
 
  // Advanced Actions
  signTransaction: (instruction: TransactionInstruction) => Promise<Transaction>;
  buildSmartWalletTransaction: (
    payer: PublicKey,
    instruction: TransactionInstruction
  ) => Promise<{
    createSessionTx: VersionedTransaction;
    executeSessionTx: VersionedTransaction;
  }>;
  createPasskeyOnly: () => Promise<ConnectResponse>;
  createSmartWalletOnly: (passkey: ConnectResponse) => Promise<{
    smartWalletAddress: string;
    account: WalletAccount;
  }>;
}

ConnectResponse

Passkey creation result with specific data formats.

interface ConnectResponse {
  publicKey: string;              // "A1B2C3D4..." (base64 encoded)
  credentialId: string;           // "cred_abc123..." (WebAuthn ID)
  isCreated: boolean;             // true = new passkey, false = existing
  connectionType: 'create' | 'get'; // Which WebAuthn method was used
  timestamp: number;              // Unix timestamp: 1640995200000
}
 
// Example response:
// {
//   publicKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A...",
//   credentialId: "cred_abc123def456ghi789",
//   isCreated: true,
//   connectionType: "create", 
//   timestamp: 1640995200000
// }

Specific Return Type Examples

// connect() returns
const account: WalletAccount = {
  publicKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A...",
  smartWallet: "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
  isConnected: true,
  isCreated: false  // false = reconnected, true = just created
};
 
// signAndSendTransaction() returns  
const signature: string = "2Xd7pLr8QZ9KvF1mN3oR4sT6uY8vW2cB1aE3fG4hI5jK...";
 
// buildSmartWalletTransaction() returns
const result: {
  createSessionTx: VersionedTransaction;  // Unsigned transaction
  executeSessionTx: VersionedTransaction; // Unsigned transaction  
} = {
  createSessionTx: VersionedTransaction { /* transaction object */ },
  executeSessionTx: VersionedTransaction { /* transaction object */ }
};

Provider Configuration

LazorkitProviderProps

interface LazorkitProviderProps {
  children: ReactNode;
  rpcUrl: string;             // Solana RPC endpoint
  paymasterUrl: string;       // Paymaster service URL  
  ipfsUrl?: string;           // Portal URL (optional)
}

Environment Setup

<LazorkitProvider
  rpcUrl={process.env.REACT_APP_RPC_URL!}
  paymasterUrl={process.env.REACT_APP_PAYMASTER_URL!}
  ipfsUrl={process.env.REACT_APP_PORTAL_URL}
>
  <App />
</LazorkitProvider>

Error Codes

type ErrorCode = 
  | 'NO_STORED_CREDENTIALS'      // First time user
  | 'USER_CANCELLED'             // User cancelled WebAuthn
  | 'INVALID_CREDENTIALS'        // Corrupted credentials
  | 'CONNECTION_FAILED'          // Network/service error
  | 'TRANSACTION_FAILED'         // Transaction execution failed
  | 'PASSKEY_CREATION_FAILED'    // Passkey creation error
  | 'SMART_WALLET_CREATION_FAILED'; // Wallet deployment error

Solana Re-exports

// Commonly used Solana types available from @lazorkit/wallet
export {
  PublicKey,
  Transaction, 
  TransactionInstruction,
  VersionedTransaction,
  SystemProgram,
  LAMPORTS_PER_SOL
} from '@solana/web3.js';

Type Guards

// Check if account is connected
function isConnected(account: WalletAccount | null): account is WalletAccount {
  return account !== null && account.isConnected;
}
 
// Usage
if (isConnected(account)) {
  console.log('Wallet:', account.smartWallet); // TypeScript knows account exists
}