@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
Addressinstead ofPublicKey - Uses
KitInstructioninstead ofTransactionInstruction - Uses
Rpc<GetAccountInfoApi>instead ofConnection
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 accountfetchMaybeSwigAccount(rpc, address, config?)- Fetch account or nullfetchNullableSwig(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 instructiongetAddAuthorityInstructions(swig, roleId, authorityInfo, actions, options?)- Add authoritygetRemoveAuthorityInstructions(swig, roleId, roleToRemoveId, options?)- Remove authoritygetSignInstructions(swig, roleId, instructions, withSubAccount?, options?)- Sign instructionsgetCreateSessionInstructions(swig, roleId, sessionKey, duration?, options?)- Create sessiongetCreateSubAccountInstructions(swig, roleId, options?)- Create sub-accountgetToggleSubAccountInstructions(swig, roleId, enabled, options?)- Toggle sub-accountgetWithdrawFromSubAccountSubAccountInstructions(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:
- Replace
ConnectionwithRpc<GetAccountInfoApi> - Replace
PublicKeywithAddress - Replace
TransactionInstructionwithKitInstruction - Make PDA derivation calls async (
await findSwigPda(id)) - 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

