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.

useWallet() returns no wallet when metamask is connected to ropsten

See original GitHub issue

As title suggests, no account address as the wallet is returned from useWallet() when connected to Ropsten using Metamask.

const { wallet } = useWallet()

console.log(wallet) // > null

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
garythungcommented, May 19, 2021

Haha, yeah that’s right. Thanks for troubleshooting with me

1reaction
WissenIstNachtcommented, May 18, 2021

Hey @garythung

The useWallet hook provides an error parameter. You can use that error to detect whether a user is on the wrong network by typechecking the error. Something like this:

const { account , error, networkName } = useWallet();

if (error instanceof ChainUnsupportedError) {
  console.log(networkName + " is not enabled");
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

useWallet() sometimes return null account value in it's object
MetaMask hides wallet addresses by default to preserve privacy. If you're using MM, you should use @web3-react/metamask .
Read more >
Ethereum Provider API - MetaMask Docs
Returns true if the provider is connected to the current chain, and false otherwise. If the provider is not connected, the page will...
Read more >
API Documentation - Binance Wallet - GitBook
The biggest difference between Binance Chain Wallet and MetaMask is we inject ... const { account, connect, reset, status } = useWallet(). return...
Read more >
@web3-onboard/react - npm
useConnectWallet. This hook allows you to connect the user's wallet and track the state of the connection status and the wallet that is...
Read more >
Chapter 2: Ethereum Basics · GitBook
It is easy to use and convenient for testing, as it is able to connect to a variety of Ethereum nodes and test...
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