#!/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);