Skip to main content
The @swig-wallet/kit package provides the same functionality as @swig-wallet/classic but is designed specifically for Web3.js 2.0 (Solana Kit) applications.

Installation

Key Differences from Classic

Type System

  • Uses Address instead of PublicKey
  • Uses KitInstruction instead of TransactionInstruction
  • Uses Rpc<GetAccountInfoApi> instead of Connection

Asynchronous PDA Derivation

Account Fetching

Basic Usage

Creating a Swig

Adding Authorities

Signing Instructions

API Reference

Account Functions

  • fetchSwig(rpc, address, config?) - Fetch a Swig account
  • fetchMaybeSwigAccount(rpc, address, config?) - Fetch account or null
  • fetchNullableSwig(rpc, address, config?) - Fetch Swig or null

PDA Functions

  • findSwigPda(id) - Derive Swig PDA (async)
  • findSwigSubAccountPda(swigId, roleId) - Derive SubAccount PDA (async)

Instruction Functions

  • getCreateSwigInstruction(args) - Create Swig instruction
  • getAddAuthorityInstructions(swig, roleId, authorityInfo, actions, options?) - Add authority
  • getRemoveAuthorityInstructions(swig, roleId, roleToRemoveId, options?) - Remove authority
  • getSignInstructions(swig, roleId, instructions, withSubAccount?, options?) - Sign instructions
  • getCreateSessionInstructions(swig, roleId, sessionKey, duration?, options?) - Create session
  • getCreateSubAccountInstructions(swig, roleId, options?) - Create sub-account
  • getToggleSubAccountInstructions(swig, roleId, enabled, options?) - Toggle sub-account
  • getWithdrawFromSubAccountSubAccountInstructions(swig, roleId, withdrawArgs, options?) - Withdraw from sub-account

Migration from Classic

The API surface is identical between @swig-wallet/classic and @swig-wallet/kit, with only type differences:
Key changes when migrating:
  1. Replace Connection with Rpc<GetAccountInfoApi>
  2. Replace PublicKey with Address
  3. Replace TransactionInstruction with KitInstruction
  4. Make PDA derivation calls async (await findSwigPda(id))
  5. Update transaction building to use Web3.js 2.0 patterns

Benefits of Web3.js 2.0

  • Enhanced Type Safety: Better TypeScript support with stricter types
  • Improved Performance: More efficient RPC handling
  • Modern Architecture: Built for the future of Solana development
  • Better Error Handling: More descriptive error messages and handling

When to Use Kit vs Classic

Use @swig-wallet/kit when:

  • Building new applications
  • Want the latest Web3.js features
  • Need enhanced type safety
  • Planning for long-term maintenance

Use @swig-wallet/classic when:

  • Working with existing Web3.js 1.x codebases
  • Need immediate compatibility
  • Have dependencies that require Web3.js 1.x
  • Want proven stability
Both packages are actively maintained and provide the same Swig functionality.