I'm building an NFT Marketplace demo. Whenever I try to click on 'Create an NFT' button, an Unhandled
Runtime Error pops up -
TypeError: Cannot read properties of undefined (reading 'length').
Call Stack
toUtf8Bytes
node_modules\@ethersproject\strings\lib.esm\utf8.js (176:20)
StringCoder.encode
node_modules\@ethersproject\abi\lib.esm\coders\string.js (12:47)
eval
node_modules\@ethersproject\abi\lib.esm\coders\array.js (49:0)
Array.forEach
<anonymous>
pack
node_modules\@ethersproject\abi\lib.esm\coders\array.js (43:0)
TupleCoder.encode
node_modules\@ethersproject\abi\lib.esm\coders\tuple.js (51:19)
AbiCoder.encode
node_modules\@ethersproject\abi\lib.esm\abi-coder.js (86:0)
Interface._encodeParams
node_modules\@ethersproject\abi\lib.esm\interface.js (253:0)
Interface.encodeFunctionData
node_modules\@ethersproject\abi\lib.esm\interface.js (295:0)
eval
node_modules\@ethersproject\contracts\lib.esm\index.js (125:0)
Generator.next
<anonymous>
fulfilled
node_modules\@ethersproject\contracts\lib.esm\index.js (5:42)
` I tried to resolve it by two methods suggested online -
Make changes to Infura 'projectId' and 'projectSecret' in .env file and change the 'createitem' function in 'create-nft.js' as well.
Downgrade the ethers.js from current version to 5.6.1, as all the later versions cause problems with Hardhat. But I don't how to downgrade ethers.js and can't find a link where it is stated clearly how to do it.