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: 0 comments
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()
![WhatsApp Image 2024-06-23 at 01 41 06](https://private-user-images.githubusercontent.com/95495030/342019441-38b38946-afc4-42d0-a7be-967166e3a82f.jpeg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2Mzg4NzEsIm5iZiI6MTcxOTYzODU3MSwicGF0aCI6Ii85NTQ5NTAzMC8zNDIwMTk0NDEtMzhiMzg5NDYtYWZjNC00MmQwLWE3YmUtOTY3MTY2ZTNhODJmLmpwZWc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjI5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyOVQwNTIyNTFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05Mjk5NGEwNTc5YzhhMTMwNmM5N2VkZGE1OGU3NTYzMDgzYzMzOTgwZjMxOWRjNzVjYmZiZWQ4MDAzYWEwNThkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.OWd9NyDvkojlqvDH8DVlYKIulTFIBo39dBvh3ZDu-28)
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Beta Was this translation helpful? Give feedback.
All reactions