useEtherBalance returns undefined
See original GitHub issueFollowing the basic example:
export function App() {
const { activateBrowserWallet, deactivate, account } = useEthers()
const userBalance = useEtherBalance(account)
return (
<div>
{!account && <button onClick={activateBrowserWallet}> Connect </button>}
{account && <button onClick={deactivate}> Disconnect </button>}
{account && <p>Account: {account}</p>}
{userBalance && <p>Ether balance: {formatEther(userBalance)} ETH </p>}
</div>
)
}
I can get my account address, but I get undefined for userBalance
, no matter what I do it is always undefined.
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (6 by maintainers)
Top Results From Across the Web
useEtherBalance returns undefined · Issue #387 - GitHub
I can get my account address, but I get undefined for userBalance , no matter what I do it is always undefined.
Read more >Reading - useDApp
useEtherBalance (address: string). Provides a way to fetch the account balance. Takes the account address as an argument and returns BigNumber or undefined...
Read more >WalletBalance.tsx Token Balance Returns : undefined
I've been completing the full-stack-defi course and when I use the useTokenBalance function from usedapp/core I get returned nothing, I don't ...
Read more >Receiving 'undefined' when using getBalance from web3
getBalance is asynchronous, so you can't assign a variable in the callback and expect that variable to be set in synchronous code after...
Read more >@ethersproject/units formatEther TypeScript Examples
export function App() { const etherBalance = useEtherBalance(STAKING_CONTRACT) return ( <div> {etherBalance && ( <div className="balance"> Staking contract ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’d use wagmi as suggested for tempo use, but definitely would love some one have useDapp checked! Thx in advance for any help.
Hey @Vanclief, I have literally one commit here, and it only affects the docs. I’m not the best person to ask about this 😄