i'm learning solana development from Buildspace and this is the tutorial source code for the next.js app https://github.com/buildspace/solana-send-sol-frontend.git

the component to display the solana balance in the connected wallet is here: https://github.com/buildspace/solana-send-sol-frontend/blob/main/components/BalanceDisplay.tsx

after a transaction to send solana is confirmed, the balance shown on the frontend does not update.

how can i change the code so that the balance is updated?

2 Answers 2


figured out a solution with onAccountChange


here's my solution https://github.com/Unboxed-Software/solana-send-sol-frontend/pull/4/files


You have 2 options to get the new balance:

either you query again the blockchain with getParsedAccountInfo(wallet_address) and you will get the new SOL balance (check https://solana-labs.github.io/solana-web3.js/classes/Connection.html#getParsedAccountInfo)

either you fetch the transaction with getParsedTransaction(signature) and you will get the new SOL balance in postBalances (check https://solana-labs.github.io/solana-web3.js/classes/Connection.html#getParsedTransaction)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.