Cannot read properties of undefined (reading 'toHexString')
See original GitHub issueEthers Version
^5.0.0
Search Terms
No response
Describe the Problem
I am trying to execute a transaction and I get
TypeError: Cannot read properties of undefined (reading 'toHexString')
at isHexable (/node_modules/@ethersproject/bytes/src.ts/index.ts:58:21)
at arrayify (/node_modules/@ethersproject/bytes/src.ts/index.ts:115:9)
at FixedBytesCoder.encode (/node_modules/@ethersproject/abi/src.ts/coders/fixed-bytes.ts:22:28)
at /node_modules/@ethersproject/abi/src.ts/coders/array.ts:71:19
at Array.forEach (<anonymous>)
at pack (//node_modules/@ethersproject/abi/src.ts/coders/array.ts:54:12)
at TupleCoder.encode (/node_modules/@ethersproject/abi/src.ts/coders/tuple.ts:54:20)
at /node_modules/@ethersproject/abi/src.ts/coders/array.ts:62:19
at Array.forEach (<anonymous>)
at pack (/node_modules/@ethersproject/abi/src.ts/coders/array.ts:54:12)
Code Snippet
https://github.com/Dimo99/light-client-smart-contract
in this repo run `npx hardhat deploy`
The json file I am loading is this one `https://github.com/metacraft-labs/eth2-light-client-updates/blob/main/mainnet/updates/00290.json`
Contract ABI
No response
Errors
TypeError: Cannot read properties of undefined (reading 'toHexString')
at isHexable (/node_modules/@ethersproject/bytes/src.ts/index.ts:58:21)
at arrayify (/node_modules/@ethersproject/bytes/src.ts/index.ts:115:9)
at FixedBytesCoder.encode (/node_modules/@ethersproject/abi/src.ts/coders/fixed-bytes.ts:22:28)
at /node_modules/@ethersproject/abi/src.ts/coders/array.ts:71:19
at Array.forEach (<anonymous>)
at pack (//node_modules/@ethersproject/abi/src.ts/coders/array.ts:54:12)
at TupleCoder.encode (/node_modules/@ethersproject/abi/src.ts/coders/tuple.ts:54:20)
at /node_modules/@ethersproject/abi/src.ts/coders/array.ts:62:19
at Array.forEach (<anonymous>)
at pack (/node_modules/@ethersproject/abi/src.ts/coders/array.ts:54:12)
Environment
Hardhat
Environment (Other)
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Cannot read properties of undefined (reading 'toHexString') in ...
Another problem you might have is where your .env is located. Make sure that your .env is in the same folder as your...
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 >"Cannot read property 'toHexString' of undefined". Try ... - Reddit
bought a new token from uniswap, but cant swap back eth and shows Unknown error: "Cannot read property 'toHexString' of undefined". Try ...
Read more >Getting 'TypeError: Cannot read properties of undefined ...
The error is thrown in the method signMessage from the EthersAdapter class: signMessage(message: string): Promise<string> { const ...
Read more >Running Error : Type Error in index.js - Alchemy Docs
... the error is : TypeError: Cannot read properties of undefined (reading 'toHexString') How can I solve this problem , Please help.
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
@Dimo99 Thats directly from the JavaScript language and runtime. There isn’t much I can do about that… it has nothing to do with ethers. If you have an undefined value (in any variable) and attempt to access a property on it, JS (correctly) complains. 😃
@ricmoo actually
fork_version
was part of my structure. This is the most minimalistic example.I know the first statement is expected to fail. But I guess
Cannot read properties of undefined (reading 'toHexString')
is not a nice message