Everytime I'm writing the code to attach the provider,I faced issue with the JsonRpcProvider-Type Error.Can anyone check and help me to fix the problem.I'm attaching the output image with it. #6663
Unanswered
gopikantagarain
asked this question in
Q&A
Replies: 1 comment
-
The interface of ethers has changed in the latest version -const provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:7545/");
+const provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:7545/"); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
const ethers = require("ethers");
const fs = require("fs-extra");
async function main() {
const provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:7545");
const wallet = new ethers.Wallet(
"0x54817de31b061ee8620792c717eb07b7f6fa8377ee52ee49d1be64c0736c8cb4",
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 deployed at address:", contract.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Beta Was this translation helpful? Give feedback.
All reactions