Architecture Overview
The v1.0 SDK has been completely refactored with a modular architecture:@swig-wallet/coder- Low-level encoding/decoding utilities@swig-wallet/lib- Core functionality@swig-wallet/classic- High-level wrapper functions for Web3.js 1.x compatibility@swig-wallet/kit- High-level wrapper functions for Web3.js 2.0 (Solana Kit) compatibility
API Reference
The canonical source for the Swig TypeScript SDK API documentation can be found at: https://anagrambuild.github.io/swig-ts/modules.htmlKey Packages
@swig-wallet/classic
For Web3.js 1.x applications, providing:
- Instruction builders returning
TransactionInstruction[] - Account fetching utilities using
Connection - PDA derivation functions (synchronous)
- Re-exports of core functionality from
@swig-wallet/lib
@swig-wallet/kit
For Web3.js 2.0 (Solana Kit) applications, providing:
- Instruction builders returning
KitInstruction[] - Account fetching utilities using
Rpc<GetAccountInfoApi> - PDA derivation functions (asynchronous)
- Same API surface as classic but with Web3.js 2.0 types
@swig-wallet/lib
Core logic including:
Actionsclass for permission managementSwigclass for wallet representation- Authority management utilities
- Instruction context builders
@swig-wallet/coder
Low-level utilities for:
- Account data encoding/decoding
- Instruction data serialization
- Type definitions
Migration from Beta Versions
Breaking Changes in v1.0:- Complete API restructure - most function signatures have changed
- Functions now return
TransactionInstruction[]instead of single instructions - Authority and Actions classes moved to
@swig-wallet/lib - New dependency on
@solana-program/tokeninstead of@solana/spl-token
Web3.js Version Support
The Swig SDK supports both major versions of the Solana Web3.js library:Web3.js 1.x (@swig-wallet/classic)
- Uses
Connection,PublicKey,TransactionInstruction - Synchronous PDA derivation
- Compatible with existing Web3.js 1.x applications
- Stable and production-ready
Web3.js 2.0 (@swig-wallet/kit)
- Uses
Rpc,Address,KitInstruction - Asynchronous PDA derivation
- Built for the new Solana Kit architecture
- Future-ready with enhanced type safety
V2 Protocol Features
The SDK now supports both v1 and v2 Swig accounts with automatic version detection:Automatic Version Detection
Enhanced Account Structure
- V1 Accounts: Traditional structure with rent exempt lamports
- V2 Accounts: Optimized structure using PDA bump seeds and system-derived wallet addresses
SignV2 Instruction
New instruction type optimized for v2 accounts with automatic selection based on account version.Program Action Management
Automatic program permission handling withensureProgramAction for streamlined authority management.
Future Development
We are actively working on expanding the SDK’s capabilities. Recent v2 improvements include:- ✅ Automatic version detection and handling
- ✅ Enhanced account structure with PDA-based addressing
- ✅ SignV2 instruction for improved performance
- ✅ Automatic program action management
- Enhanced session management
- Additional authority types
- Integration with Gill
- Performance optimizations

