Replies: 2 comments
-
Can you please change this thread to Q&A and use this please ==> https://github.com/smartcontractkit/full-blockchain-solidity-course-js/blob/main/how-to-ask-a-question.md |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I keep getting this error,
TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')
Here's my code....
// SPDX-License-Identifier: MIT
//struct is used to create a list with different variables
//arrays store different lists
pragma solidity ^0.8.14;
contract SimpleStorage {
uint256 favouriteNumber;
People public person = People({favouriteNumber: 2, name: "Bilal"});
}
{
"dependencies": {
"ethers": "^5.7.0",
"fs-extra": "^11.1.0",
"solc": "^0.8.19"
},
"scripts": {
"compile": "yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol"
}
}
const ethers = require("ethers");
const fs = require("fs-extra");
async function main() {
const provider = new ethers.prodivers.JsonRpcProvider(
"http://127.0.0.1:7545"
);
const wallet = new ethers.Wallet(
"0xb88d03505701db297c497a32663797652b5d951c781b3c2262fb8d0308931dad",
provider
);
const abi = fs.readFileSync("./SimpleStorage_sol_SimepleStorage.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(); //only in async contracts
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