TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider') #4724
-
Hi All I was getting the following error at 7:07 while trying to deploy first contract in VS: I found a thread that said if i change ethers version to 5.7.2 via 'yarn add ethers@5.7.2' it would solve the problem. However I got a new error message as follows: My deploy.js code is as follows: async function main() { It seems to be a problem in index.js? Any help is much appreciated Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
Have you installed ether dependencies? before using JsonRpcProvider I hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Hi - see package.json below: { Thanks! |
Beta Was this translation helpful? Give feedback.
-
Ahh.. Thanks. Silly mistake... However once I fixed that I got a new error message: Error: invalid bytecode (argument="bytecode", value="[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"uint256","name":"_favoriteNumber","type":"uint256"}],"name":"addPerson","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"nameToFavoriteNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"people","outputs":[{"internalType":"uint256","name":"favoriteNumber","type":"uint256"},{"internalType":"string","name":"name","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"retrieve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_favoriteNumber","type":"uint256"}],"name":"store","outputs":[],"stateMutability":"nonpayable","type":"function"}]", code=INVALID_ARGUMENT, version=contracts/5.7.0) Appreciate your patience ! |
Beta Was this translation helpful? Give feedback.
-
it seems like something is not right with your solidity code, can you compile your code first and see if you coming across any issues there? It will be helpful if you can paste your solidity code here. |
Beta Was this translation helpful? Give feedback.
-
Hi - solidity code is a direct copy from the repository.. I accidently closed remix: pragma solidity 0.8.7; // pragma solidity ^0.8.0; contract SimpleStorage {
} |
Beta Was this translation helpful? Give feedback.
Hi - see package.json below:
Also - the JsonRpcProvider is the local ganache server address
{
"dependencies": {
"ethers": "5.7.2",
"fs-extra": "^11.1.0",
"solc": "0.8.7-fixed"
},
"scripts": {
"compile": "yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol"
}
}
Thanks!