question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useEtherBalance returns undefined

See original GitHub issue

Following 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:closed
  • Created 2 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
wanaiicommented, May 6, 2022

I’d use wagmi as suggested for tempo use, but definitely would love some one have useDapp checked! Thx in advance for any help.

2reactions
hasparuscommented, Nov 17, 2021

Hey @Vanclief, I have literally one commit here, and it only affects the docs. I’m not the best person to ask about this 😄

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found