GlamClient class is the main entry point for the GLAM SDK. It uses lazy initialization to load sub-clients only when needed, optimizing performance and resource usage.
GlamClient extends BaseClient, which provides:
- Connection Management: Handles Solana RPC connections
- Transaction Processing: Sign, send, and confirm transactions
- Program Integration: Interfaces with GLAM Protocol programs
Initialization
InitializeGlamClient with the default Anchor provider and wallet:
GlamClientConfig object:
Sub-clients
Sub-clients are lazily loaded on first access. For a comprehensive list, see client.ts.Transaction Builder
Each sub-client provides aTxBuilder instance for constructing instructions and transactions.
Building Instructions
To build an instruction that enables Jupiter Swap on a vault:Building Transactions
To build a complete transaction:Sending Transactions
Convert a legacy transaction to a versioned transaction and send it:Transaction Options
Most client methods accept an optionalTxOptions parameter:
TxOptions type provides additional configuration for transactions:
signer: Override the default signercomputeUnitLimit: Set the compute unit limitgetPriorityFeeMicroLamports: Callback function to calculate dynamic priority feesmaxFeeLamports: Set the maximum priority feeuseMaxFee: Use the maximum priority feepreInstructions: Add instructions before the main instructionlookupTables: Include address lookup tablessimulate: Simulate the transaction before sending
State Model
The SDK abstracts on-chain vault state using theStateModel class, which defines the vault’s configuration at creation time.
state-model.ts
Fetching Vault State
Fetch the state of the active vault:Mint Model
The SDK represents on-chain mint data using theMintModel class, which defines the tokenized vault’s configuration at creation time.
mint-model.ts
Accessing Mint Model
Access theMintModel of a tokenized vault via its stateModel:
Use Staging Programs
To use staging programs, make sure env variableNEXT_PUBLIC_GLAM_STAGING or GLAM_STAGING, is set to true.