SwigInstructionBuilder is a fundamental component of the Swig SDK that handles the creation and management of Solana instructions for the Swig protocol.
Overview
The instruction builder provides low-level functionality for creating various types of instructions needed to interact with Swig wallets on the Solana blockchain.Core Components
AuthorityManager
AuthorityManager enum represents different types of signing authorities supported by the Swig protocol.
SwigInstructionBuilder
Core Functions
Creating a New Instance
Building a Swig Account
Signing Instructions
Authority Management
Adding Authorities
Removing Authorities
Replacing Authorities
Session Management
Creating Sessions
Utility Functions
Getting the Swig Account
Getting the Role ID
Switching Authority
SubAccount Management
Creating SubAccounts
New in v1.4.0: Support for multiple subaccounts per role (indices 0-254).sub_account_index: The index of the subaccount to create (0-254). Index 0 uses legacy PDA derivation for backwards compatibility.
Deriving SubAccount PDAs
derive_sub_account_pda function automatically handles:
- Index 0: Uses legacy 3-seed PDA derivation for backwards compatibility
- Indices 1-254: Uses new 4-seed PDA derivation with index in seeds

