🚀 Fix Drift Protocol integration - Connection now working
✅ Key fixes: - Bypass problematic SDK subscription that caused 410 Gone errors - Use direct account verification without subscription - Add fallback modes for better reliability - Switch to Helius RPC endpoint for better rate limits - Implement proper error handling and retry logic 🔧 Technical changes: - Enhanced drift-trading.ts with no-subscription approach - Added Drift API endpoints (/api/drift/login, /balance, /positions) - Created DriftAccountStatus and DriftTradingPanel components - Updated Dashboard.tsx to show Drift account status - Added comprehensive test scripts for debugging 📊 Results: - Connection Status: Connected ✅ - Account verification: Working ✅ - Balance retrieval: Working ✅ (21.94 total collateral) - Private key authentication: Working ✅ - User account: 3dG7wayp7b9NBMo92D2qL2sy1curSC4TTmskFpaGDrtA 🌐 RPC improvements: - Using Helius RPC for better reliability - Added fallback RPC options in .env - Eliminated rate limiting issues
This commit is contained in:
39
verify-key.js
Normal file
39
verify-key.js
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Quick test to verify private key usage
|
||||
*/
|
||||
|
||||
require('dotenv').config();
|
||||
|
||||
async function quickTest() {
|
||||
console.log('🔐 Quick private key verification...');
|
||||
|
||||
try {
|
||||
const { Connection, Keypair } = require('@solana/web3.js');
|
||||
|
||||
// This is exactly what our drift-trading.ts does
|
||||
const secret = process.env.SOLANA_PRIVATE_KEY;
|
||||
if (!secret) {
|
||||
throw new Error('SOLANA_PRIVATE_KEY not found');
|
||||
}
|
||||
|
||||
const keypair = Keypair.fromSecretKey(Buffer.from(JSON.parse(secret)));
|
||||
const connection = new Connection(process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com', 'confirmed');
|
||||
|
||||
console.log('✅ Private key parsed successfully');
|
||||
console.log('🔑 Public key:', keypair.publicKey.toString());
|
||||
|
||||
// Quick balance check
|
||||
const balance = await connection.getBalance(keypair.publicKey);
|
||||
console.log('💰 SOL balance:', (balance / 1e9).toFixed(6), 'SOL');
|
||||
|
||||
console.log('\n✅ Your private key from .env is working correctly!');
|
||||
console.log('📝 The issue is likely with Drift SDK subscription or user account initialization.');
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Private key test failed:', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
quickTest().catch(console.error);
|
||||
Reference in New Issue
Block a user