Cannot read property '_hex' of undefined
See original GitHub issueI’m attempting to use a provider/signer obtained from web3Modal and WalletConnect, and then call a Contract method.
const providerOptions = {
walletconnect: {
package: window.WalletConnectProvider.default,
options: {
infuraId: INFURAID,
}
}
};
web3Modal = new window.Web3Modal.default({
cacheProvider: false,
providerOptions,
disableInjectedProvider: false
});
web3Provider = await web3Modal.connect();
provider = new ethers.providers.Web3Provider(web3Provider).provider;
signer = new ethers.providers.Web3Provider(web3Provider).getSigner();
contract = new ethers.Contract(CONTRACTADDRESS, CONTRACTABI, signer);
The next line throws an error:
tx = await contract.myMethod(PARAM1, ethers.utils.formatBytes32String(STRINGPARAM2));
Uncaught TypeError: Cannot read property '_hex' of undefined
This all works just fine when NOT using web3Modal/WalletConnect as a provider, and instead relying on injected MetaMask. I’m not sure what to do or even how to start debugging this. Any help would be wildly appreciated!
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
Cannot read property 'hex' of undefined (only with v2.3.0) #248
Hi,. I use chalk to add colors to console logs in a personal project (create-cozy-app) and thanks a lot for your great job...
Read more >react-color Cannot read property 'value' of undefined
It's a very specific error which tells you exactly what the problem is. e.target is undefined , so whatever e is, it has...
Read more >Cannot read properties of undefined (reading 'toHexString')
Hey Devs I want to interact with this smart contract function but i get this error Cannot read properties of undefined (reading ...
Read more >A brand new website interface for an even better experience!
Cannot read property 'hex' of undefined.
Read more >VUEJS - Cannot read properties of null (reading 'hex')"
It's probably not rendering at runtime, so there's a problem accessing the hex element. After loading, he will have access.
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 FreeTop 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
Top GitHub Comments
great advice with the console.log. I will try to do that more as I can see how it is helpful along the way. I managed to get it to work by adding quotations in my .env file when defining the variable. I appreciate your help! NEXT_PUBLIC_METAMASK_KEY = YOURPRIVATEKEY NEXT_PUBLIC_METAMASK_KEY = “YOURPRIVATEKEY”
On Wed, Mar 2, 2022 at 11:01 PM Richard Moore @.***> wrote:
Note: the createToken function reverts if a token was already created for the same address and ticket number. This causes ethers to throw BigNumber conversion error in estimateGas for the InfuraProvider. Will create an issue for this later.