Error: cannot estimate gas; transaction may fail or may require manual gas limit #1274
-
when I try to apply lesson 5 with Rinkeby network I have an error say (Error: cannot estimate gas; transaction may fail or may require manual gas limit) how to solve it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
@mazen-sleem There could be many reasons for it, need more clarification. Please follow this guide next time when you ask a question. How to Ask Question Guide |
Beta Was this translation helpful? Give feedback.
-
this is the code : const ethers = require("ethers")
const fs = require("fs-extra")
require("dotenv").config()
async function main() {
let provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL)
const encryptedJson = fs.readFileSync("./.encryptedKey.json", "utf8");
let wallet = new ethers.Wallet.fromEncryptedJsonSync(
encryptedJson,
process.env.PRIVATE_KEY_PASSWORD
);
wallet = wallet.connect(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()
const deploymentReceipt = await contract.deployTransaction.wait(1)
console.log(`Contract deployed to ${contract.address}`)
let currentFavoriteNumber = await contract.retrieve()
console.log(`Current Favorite Number: ${currentFavoriteNumber}`)
console.log("Updating favorite number...")
let transactionResponse = await contract.store(7)
let transactionReceipt = await transactionResponse.wait()
currentFavoriteNumber = await contract.retrieve()
console.log(`New Favorite Number: ${currentFavoriteNumber}`)
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
}) and the error is : Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] |
Beta Was this translation helpful? Give feedback.
this is the code :