Transaction History Development Tutorials, Guides & Insights
Unlock 1+ expert-curated transaction history tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your transaction history 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.
Tutorial
javascript json
Fetching Address Details from Solana
Finally, let's fetch the token holdings of the wallet:
async function getTokenHoldings(walletAddress) {
try {
const publicKey = new solanaWeb3.PublicKey(walletAddress);
const tokenAccounts = await connection.getParsedTokenAccountsByOwner(publicKey, {
programId: solanaWeb3.TOKEN_PROGRAM_ID,
});
console.log('Token Holdings:');
tokenAccounts.value.forEach((tokenAccount) => {
const tokenAmount = tokenAccount.account.data.parsed.info.tokenAmount.uiAmount;
const tokenMint = tokenAccount.account.data.parsed.info.mint;
console.log(`- Token Mint: ${tokenMint}`);
console.log(` Amount: ${tokenAmount}`);
});
} catch (error) {
console.error('Error fetching token holdings:', error);
}
}
getTokenHoldings(walletAddress);Aug 09, 2024
Read More