Context type defines the network configuration for connecting to Drift Protocol on different Solana networks.
Overview
- Market lookup tables (LUTs) for transaction compression
- Pyth oracle program ID
- Network identifier
Constants
Context::MainNet
Use this for production MainNet connections.Context::DevNet
Use this for DevNet testing.Methods
luts()
Get the address lookup tables for this network.pyth_program_id()
Get the Pyth oracle program ID for this network.name()
Get the network name."mainnet" or "devnet".
Lookup Tables
Lookup tables (LUTs) are used to compress transactions by storing frequently used addresses. The Drift program uses lookup tables to reduce transaction sizes. MainNet LUTs:Usage with TransactionBuilder
The Context is automatically used when creating transactions:Oracle Program IDs
Each network uses a different Pyth program address: MainNet Pyth:Network Selection Best Practices
Always use the correct Context for your network
- Use
Context::MainNetfor production applications - Use
Context::DevNetfor testing and development - Never mix contexts (e.g., MainNet context with DevNet RPC)
Complete Example
See Also
- DriftClient - Main client API
- Wallet - Key management