The Solana network endpoint to connect to.
The public key of the account whose balance is to be fetched.
const run = async () => {
const solanaEndpoint = 'https://api.mainnet-beta.solana.com';
const publicKey = 'YourPublicKeyHere';
try {
const balance = await getSolBalance(solanaEndpoint, publicKey);
console.log(`Balance in lamports: ${balance}`);
} catch (error) {
console.error('Error:', error);
}
}
run();
Generated using TypeDoc
Retrieves the SOL balance in lamports for a given Solana public key.