Files
trading_bot_v3/test-basic-connection.js
mindesbunister e985a9ec6f 🚀 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
2025-07-13 00:20:01 +02:00

49 lines
1.4 KiB
JavaScript
Executable File

#!/usr/bin/env node
/**
* Simple Drift connection test
*/
const { Connection, Keypair, PublicKey } = require('@solana/web3.js');
async function testConnection() {
console.log('🔍 Testing basic Solana connection...');
try {
// Test environment variables
const rpcUrl = process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com';
const privateKeyString = process.env.SOLANA_PRIVATE_KEY;
console.log(`📡 RPC URL: ${rpcUrl}`);
console.log(`🔑 Private key exists: ${!!privateKeyString}`);
if (!privateKeyString) {
console.log('❌ SOLANA_PRIVATE_KEY not found in environment');
return;
}
// Test private key parsing
const privateKey = JSON.parse(privateKeyString);
console.log(`🔢 Private key length: ${privateKey.length}`);
// Test keypair creation
const keypair = Keypair.fromSecretKey(Buffer.from(privateKey));
console.log(`🏠 Public key: ${keypair.publicKey.toString()}`);
// Test connection
const connection = new Connection(rpcUrl, 'confirmed');
const balance = await connection.getBalance(keypair.publicKey);
console.log(`💰 SOL balance: ${balance / 1e9} SOL`);
console.log('✅ Basic connection test successful!');
} catch (error) {
console.error('❌ Basic connection test failed:', error.message);
}
}
// Load environment variables
require('dotenv').config();
testConnection().catch(console.error);