Problem with deployment. #6320
Replies: 3 comments 4 replies
-
i installed ethers with npm instead of yarn and it worked |
Beta Was this translation helpful? Give feedback.
-
have your same issue. this is the code which looks ok to me: async function main() { main() I run command: node deploy.js from terminal and get the following error: Looks like it cannot connect to the ganache blockchain or something similar |
Beta Was this translation helpful? Give feedback.
-
Hey guys, I think they change the syntax a little. You just need to change the declaration of provider to the following const provider = new ethers.JsonRpcProvider("http://127.0.0.1:7545/"); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I'm in lesson 4 and on the ethers chapter.
I just tried to deploy my code after adding the ethers and fs-extra.
having added all the const i am hit with the particular error below when trying to deploy.
/ether-simple-storage# node deploy.js
TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')
at main (/root/ether-simple-storage/deploy.js:6:40)
at Object. (/root/ether-simple-storage/deploy.js:22:1)
I am a bit confused as i checked the code itself and i am not sure of where the problem is coming from.
here is the code i used in my VS code
`const ethers = require("ethers");
const fs = require("fs-extra");
// http://127.0.0.1:7545
async function main() {
constprovider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:7545");
const wallet = new ethers.wallet(
0xf7ee25516153f537c57cd6c414514df887e8b89e4f8c1960d102446bc80bb8a9,
provider
);
const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8");
const binary = fs.readFileSync(
"./SimpleStorage_sol_SimpleStorage.bin",
"utf8"
);
const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
console.log("Deploying, Please wait...");
const contract = await contractFactory.deploy();
console.log(contract);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});`
Beta Was this translation helpful? Give feedback.
All reactions