Migration Guides
Comprehensive upgrade instructions for migrating between major versions of the GhostSpeak SDK, including code examples and troubleshooting tips.
Quick Migration Reference
From To Difficulty Breaking Changes Time Estimate 1.x → 2.x Guide Medium Yes (5 changes) 2-4 hours 2.0 → 2.1 Guide Low No 30 minutes Devnet → Mainnet Guide Low Config only 15 minutes
v1.x to v2.x Migration
Breaking Changes : v2.0 introduces several breaking changes. Review this guide carefully before upgrading.
Overview
Major Changes:
Required cluster parameter in client constructor
Changed return types for agent operations
New error handling system
Solana Web3.js v2 migration (modular packages)
Deprecated ConnectionManager class
Timeline : Allow 2-4 hours for migration and testing.
Step 1: Update Dependencies
# Remove old version
bun remove @ghostspeak/sdk
# Install new version
bun add @ghostspeak/sdk@latest
# Update peer dependencies
bun add @solana/kit@latest @solana/rpc@latest @solana/addresses@latest
Check package.json:
{
"dependencies" : {
"@ghostspeak/sdk" : "^2.0.7" ,
"@solana/kit" : "^5.1.0" ,
"@solana/rpc" : "^5.1.0" ,
"@solana/addresses" : "^5.1.0" ,
"@solana/signers" : "^5.1.0"
}
}
Step 2: Update Client Initialization
Before (v1.x):
import { GhostSpeakClient } from '@ghostspeak/sdk'
// Cluster was optional, defaulted to devnet
const client = new GhostSpeakClient ()
// Or with custom RPC
const client = new GhostSpeakClient ({
rpcUrl: 'https://api.devnet.solana.com'
})
After (v2.x):
import { GhostSpeakClient } from '@ghostspeak/sdk'
// Cluster is now required
const client = new GhostSpeakClient ({
cluster: 'devnet' , // Required: 'devnet' or 'mainnet-beta'
})
// With custom RPC
const client = new GhostSpeakClient ({
cluster: 'devnet' ,
rpcUrl: 'https://devnet.helius-rpc.com/?api-key=YOUR_KEY' ,
})
Migration Checklist:
✅ Add cluster: 'devnet' to all GhostSpeakClient constructors
✅ Replace cluster: 'localnet' with cluster: 'devnet'
✅ Update test fixtures to include cluster parameter
Step 3: Update Return Types
Before (v1.x):
// Agent registration returned just the address
const agentId : string = await client . agents . register ( signer , {
name: 'My Agent' ,
capabilities: [ 'chat' ],
model: 'gpt-4' ,
})
console . log ( 'Agent ID:' , agentId )
After (v2.x):
// Agent registration returns full transaction result
const result = await client . agents . register ( signer , {
name: 'My Agent' ,
capabilities: [ 'chat' ],
model: 'gpt-4' ,
})
console . log ( 'Agent Address:' , result . address )
console . log ( 'Transaction Signature:' , result . signature )
console . log ( 'Explorer:' , `https://solscan.io/tx/ ${ result . signature } ?cluster=devnet` )
Migration Pattern:
// Find all instances of:
const agentId = await client . agents . register ( ... )
// Replace with:
const { address : agentId , signature } = await client . agents . register ( ... )
Step 4: Migrate to New Error Handling
Before (v1.x):
try {
const agent = await client . agents . getAgent ( agentId )
} catch ( error ) {
// String matching and generic error handling
if ( error . message . includes ( 'not found' )) {
console . log ( 'Agent not found' )
} else if ( error . message . includes ( 'network' )) {
console . log ( 'Network error' )
} else {
console . error ( 'Unknown error:' , error )
}
}
After (v2.x):
import {
AccountNotFoundError ,
NetworkError ,
GhostSpeakError ,
formatErrorForUser ,
} from '@ghostspeak/sdk/errors'
try {
const agent = await client . agents . getAgent ( agentId )
} catch ( error ) {
// Typed error handling with rich context
if ( error instanceof AccountNotFoundError ) {
console . log ( 'Agent not found:' , error . address )
console . log ( 'Account Type:' , error . accountType )
} else if ( error instanceof NetworkError ) {
console . log ( 'Network error (will retry automatically)' )
} else if ( error instanceof GhostSpeakError ) {
// All SDK errors have user-friendly messages
console . error ( formatErrorForUser ( error ))
} else {
console . error ( 'Unexpected error:' , error )
}
}
Benefits:
Type-safe error handling
Automatic retry for retryable errors
User-friendly error messages
Structured error logging
Step 5: Migrate Solana Web3.js Imports
Before (v1.x):
import {
Connection ,
PublicKey ,
Keypair ,
Transaction ,
} from '@solana/web3.js'
const connection = new Connection ( 'https://api.devnet.solana.com' )
const pubkey = new PublicKey ( '4wHjA2a5YC4twZb4NQpwZpixo5FgxxzuJUrCG7UnF9pB' )
const keypair = Keypair . generate ()
After (v2.x):
import { createSolanaRpc } from '@solana/rpc'
import { address } from '@solana/addresses'
import { generateKeyPairSigner } from '@solana/signers'
const rpc = createSolanaRpc ( 'https://api.devnet.solana.com' )
const programAddress = address ( '4wHjA2a5YC4twZb4NQpwZpixo5FgxxzuJUrCG7UnF9pB' )
const signer = await generateKeyPairSigner ()
Migration Table:
v1.x API v2.x API new Connection(url)createSolanaRpc(url)new PublicKey(addr)address(addr)Keypair.generate()await generateKeyPairSigner()connection.getAccountInfo()rpc.getAccountInfo().send()connection.getLatestBlockhash()rpc.getLatestBlockhash().send()
Find & Replace:
# Find all PublicKey usage
grep -r "PublicKey" src/
# Find all Connection usage
grep -r "new Connection" src/
# Find all Keypair usage
grep -r "Keypair" src/
Step 6: Remove Deprecated APIs
Deprecated: ConnectionManager class
Before (v1.x):
import { ConnectionManager } from '@ghostspeak/sdk'
const manager = new ConnectionManager ({
cluster: 'devnet' ,
poolSize: 5 ,
})
const connection = manager . getConnection ()
After (v2.x):
import { GhostSpeakClient } from '@ghostspeak/sdk'
// GhostSpeakClient manages connections internally
const client = new GhostSpeakClient ({
cluster: 'devnet' ,
// Connection pooling is automatic
})
// Access RPC client if needed
const rpc = client . rpc
Step 7: Update Tests
Test Configuration Changes:
// tests/setup.ts
// Before (v1.x)
const client = new GhostSpeakClient ()
// After (v2.x)
const client = new GhostSpeakClient ({ cluster: 'devnet' })
Mock Updates:
// Before (v1.x)
vi . mock ( '@solana/web3.js' , () => ({
Connection: vi . fn (),
PublicKey: vi . fn (),
}))
// After (v2.x)
vi . mock ( '@solana/rpc' , () => ({
createSolanaRpc: vi . fn (),
}))
vi . mock ( '@solana/addresses' , () => ({
address: vi . fn (( addr : string ) => addr ),
}))
Step 8: Verification Checklist
Build Succeeds
bun run build
# Should complete without errors
Tests Pass
bun test
# All tests should pass
Type Check Passes
bun run type-check
# No TypeScript errors
Runtime Testing
Test key flows in devnet:
Agent registration
Credential issuance
Reputation updates
Common Migration Issues
TypeError: cluster is not defined
Cause : Missing cluster parameter in client constructor.Fix: const client = new GhostSpeakClient ({ cluster: 'devnet' })
Cannot destructure 'address' of result
Cause : Expecting old return type (string) instead of new object.Fix: // Old
const agentId = await client . agents . register ( ... )
// New
const { address , signature } = await client . agents . register ( ... )
Module '@solana/web3.js' not found
Cause : Need to install new modular Solana packages.Fix: bun add @solana/kit @solana/rpc @solana/addresses @solana/signers
Error instanceof checks failing
Cause : Import errors from old error module.Fix: import { AccountNotFoundError } from '@ghostspeak/sdk/errors'
v2.0 to v2.1 Migration
Status : Planned for Q1 2026 (Mainnet launch)Breaking Changes : None (backward compatible)
Overview
v2.1 will be backward compatible with v2.0. The main change is adding mainnet support.
Step 1: Update Dependencies
Step 2: Add Mainnet Configuration (Optional)
// Devnet (existing, no changes needed)
const devClient = new GhostSpeakClient ({ cluster: 'devnet' })
// Mainnet (new)
const mainnetClient = new GhostSpeakClient ({ cluster: 'mainnet-beta' })
No code changes required for existing devnet applications.
Devnet to Mainnet Migration
Coming Q1 2026 : Mainnet deployment is not yet available. This is a preview guide.
Overview
Migrating from devnet to mainnet requires only configuration changes, no code modifications.
Step 1: Environment Configuration
Before (Devnet):
// .env
GHOSTSPEAK_CLUSTER = devnet
SOLANA_RPC_URL = https : //api.devnet.solana.com
After (Mainnet):
// .env
GHOSTSPEAK_CLUSTER = mainnet - beta
SOLANA_RPC_URL = https : //api.mainnet-beta.solana.com
Step 2: Update Client Configuration
const client = new GhostSpeakClient ({
cluster: process . env . GHOSTSPEAK_CLUSTER as 'devnet' | 'mainnet-beta' ,
rpcUrl: process . env . SOLANA_RPC_URL ,
})
Step 3: Pre-Migration Checklist
Test on Devnet
Thoroughly test all functionality on devnet before mainnet migration
Fund Mainnet Wallet
Ensure production wallet has sufficient SOL for operations
Update RPC Provider
Use production-grade RPC (Helius, QuickNode) for reliability
Review Security
Secure private keys in production environment
Enable monitoring and alerting
Test error handling for mainnet conditions
Deploy Configuration
Update deployment configuration to use mainnet cluster
Mainnet Considerations
Cost Differences:
Devnet SOL is free (from faucets)
Mainnet SOL costs real money
Budget for transaction costs and rent
RPC Requirements:
Free public RPCs have strict rate limits
Use paid RPC provider for production (Helius, QuickNode)
Monitoring:
Set up transaction monitoring
Configure alerts for failures
Track SOL balance to prevent insufficient funds
Deprecated Features Timeline
Current Deprecations (v2.x)
Feature Deprecated In Removal Target Alternative ConnectionManagerv2.0.0 v3.0.0 GhostSpeakClientcluster: 'localnet'v2.0.0 v3.0.0 cluster: 'devnet'Legacy error classes v2.0.0 v3.0.0 GhostSpeakError hierarchy@solana/web3.js v1v2.0.0 v3.0.0 @solana/kit
Deprecation Warning Example
// This will show deprecation warning in v2.x
const manager = new ConnectionManager ({ cluster: 'devnet' })
// Warning: ConnectionManager is deprecated. Use GhostSpeakClient instead.
Upcoming Features
v2.1.0 (Q1 2026)
Mainnet Support:
Production program deployment
Mainnet GHOST token integration
Enhanced monitoring for production use
New Features:
Additional credential types (Skill Badges, Compliance)
Advanced governance (Quadratic voting, Delegation)
Performance optimizations for high-throughput apps
v3.0.0 (Q2 2026)
Breaking Changes:
Removal of all v2.0 deprecated features
New credential schema format
Enhanced privacy features with ZK proofs
New Features:
Zero-knowledge credential verification
Multi-chain expansion (EVM L2s)
Advanced analytics and reporting
Migration Support
Migration Questions? Join our Discord #migrations channel for personalized help.