Skip to main content

Swig SDK V2 Protocol Features

This guide demonstrates the key features introduced in Swig SDK v2, including automatic version detection, enhanced account structure, and improved instruction handling.

Automatic Version Detection

The SDK automatically detects whether a Swig account is v1 or v2:

Enhanced Account Structure

V2 accounts use an optimized structure with PDA-based addressing:

Automatic Instruction Selection

The SDK automatically chooses the correct instruction type based on account version:

Complete V2 Example

Here’s a complete example demonstrating v2 features:

Enhanced Program Action Management

V2 includes automatic program action management:

Version-Aware Development

Best practices for working with both v1 and v2 accounts:

Key Benefits

Backward Compatibility

  • All existing v1 code works without changes
  • Automatic version detection eliminates manual configuration
  • Same API surface for both account versions

Performance Improvements

  • V2 accounts use optimized storage structure
  • PDA-based addressing provides better isolation
  • Reduced account size and transaction costs

Enhanced Developer Experience

  • Automatic instruction selection
  • Built-in program action management
  • Version-aware debugging utilities

The v2 protocol improvements provide enhanced performance and developer experience while maintaining full backward compatibility with existing Swig applications.