Wallet Address Development Tutorials, Guides & Insights
Unlock 1+ expert-curated wallet address tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your wallet address skills on DeveloperBreeze.
Adblocker Detected
It looks like you're using an adblocker. Our website relies on ads to keep running. Please consider disabling your adblocker to support us and access the content.
Fetching Address Details from Solana
Tutorial August 09, 2024
javascript json
async function getWalletBalance(walletAddress) {
try {
const publicKey = new solanaWeb3.PublicKey(walletAddress);
const balance = await connection.getBalance(publicKey);
console.log(`Wallet Balance: ${balance / solanaWeb3.LAMPORTS_PER_SOL} SOL`);
} catch (error) {
console.error('Error fetching wallet balance:', error);
}
}
// Replace with your Solana wallet address
const walletAddress = 'YourWalletAddressHere';
getWalletBalance(walletAddress);This function takes a wallet address, converts it to a PublicKey object, and uses the getBalance method to fetch the balance in lamports (the smallest unit of SOL). It then converts lamports to SOL for display.