feat(dashboard): integrate real STRK and STRKP balances#557
Conversation
|
Hello @Sendi0011 , Thank you for your work. Since we’re participating in the StarkNet Hackathon, we need to pause the submission of commits and merging of PRs because this week was the submission deadline, and we’ve been informed that the project must not have any changes after the cutoff date for review. Therefore, your PR will be reviewed until further notice. Over the weekend, I’ll download your PR and test it so we can see if I need to provide any feedback. For now, I’d appreciate it if you could check the workflow errors, as it’s currently failing. |
- Add formatBalance utility to convert wei to decimal format - Read STRKP token balance from StarkPlayERC20 contract - Read STRK token balance from StarkPlayVault contract - Implement loading states while fetching balances - Use connected user address via useAccount hook - Format values to 2 decimals for UI display - Handle wallet disconnection gracefully Closes FutureMindsTeam#554
434c6bc to
2abb91e
Compare
GM Thanks for the update, @davidmelendez , I’ve fixed the workflow errors. Appreciate the heads-up and will wait for your review. |
|
Hello @Sendi0011, Can you please check the error CI? |
GM @davidmelendez i just made changes to that |
📌 Description
Replaced mock balance data in the BalancesCard component with real STRK and STRKP token balances fetched dynamically from the connected user's wallet using Scaffold-Stark hooks.
Previously, the dashboard displayed hardcoded mock values (123.45 STRKP, 0.78 STRK). Now it reads actual token balances from smart contracts and updates them in real-time when the user connects/disconnects their wallet.
🎯 Motivation and Context
Users need to see their actual token holdings on the dashboard. This is essential for:
The implementation resolves the disconnect between the UI and actual blockchain data, making the dashboard a reliable source of truth for user balances.
Closes #554
🛠️ How to Test the Change (if applicable)
http://localhost:3000/dapp/dashboard🖼️ Screenshots (if applicable)
Before: Mock data showing "123.45 STRKP, 0.78 STRK"

After: Real balances showing actual wallet holdings with loading states
🔍 Type of Change
✅ Checklist Before Merging
📌 Additional Notes
Files Modified
Implementation Details
Balance Reading Strategy:
useAccounthook from @starknet-react/core to get connected wallet addressuseScaffoldReadContractto callbalanceOf(userAddress)on StarkPlayERC20 contractuseScaffoldReadContractto fetch STRK balance from StarkPlayVault contractformatBalance()helper function (converts from wei to decimal)Key Functions:
formatBalance(balance, decimals, displayDecimals)- Converts wei to readable decimalsContract Functions Used:
StarkPlayERC20.balanceOf(account)- Returns STRKP balance in weiStarkPlayVault.get_total_strk_stored()- Returns STRK balance infoTesting Notes
Known Limitations
Related Issues