-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_wallet.js
More file actions
27 lines (21 loc) · 781 Bytes
/
Copy pathdebug_wallet.js
File metadata and controls
27 lines (21 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { Connection, Keypair } = require('@solana/web3.js');
require('dotenv').config();
async function check() {
const RPC = process.env.SOLANA_RPC_URL;
const KEY = process.env.SOLANA_PRIVATE_KEY;
if (!KEY) {
console.error("Configuration error: Missing required credentials.");
return;
}
try {
const secretKey = Buffer.from(KEY, 'hex');
const wallet = Keypair.fromSecretKey(secretKey);
console.log("Wallet Public Key:", wallet.publicKey.toString());
const connection = new Connection(RPC, 'confirmed');
const balance = await connection.getBalance(wallet.publicKey);
console.log(`Balance: ${balance / 1e9} SOL`);
} catch (e) {
console.error("Error:", e.message);
}
}
check();