Lesson 5: Deploying contract on a alchemy test network #5554
Answered
by
MahzyarSaadat
MahzyarSaadat
asked this question in
Q&A
-
hi,
also this is my code const ethers = require("ethers");
const fs = require("fs");
require("dotenv").config();
async function main() {
const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
const bin = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.bin", "utf-8");
const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf-8");
const contractFactory = new ethers.ContractFactory(abi, bin, wallet);
const contract = await contractFactory.deploy();
console.log("Contract Deploying...");
await contract.deployTransaction.wait(1);
//inneract with contat
const getFavouriteNumber = await contract.retrive();
console.log(`favourite number is : ${getFavouriteNumber.toString()}`);
const setFavouriteNumber = await contract.store("7");
await setFavouriteNumber.wait(1);
const updatedFaouriteNumber = await contract.retrive();
console.log(
`updated favouriteNumber is : ${updatedFaouriteNumber.toString()}`
);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.log(error);
process.exit(1);
}); i entered the RPC_URL correctly and also the PROVATE_KEY |
Beta Was this translation helpful? Give feedback.
Answered by
MahzyarSaadat
May 29, 2023
Replies: 2 comments 6 replies
-
@mahziarwoas Please check this discussion #286 |
Beta Was this translation helpful? Give feedback.
5 replies
-
@mahziarwoas
to this
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@alymurtazamemon
I use Ankr site to provide RPC for sepolia test network insted of Alchemy and all run correctly.
I think it was a problem with alckemy.