smartcontractkit / full-blockchain-solidity-course-js

Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript
11.94k stars 2.89k forks source link

Error: cannot estimate gas; transaction may fail or may require manual gas limit #6348

Open Clintontrillz opened 6 months ago

Clintontrillz commented 6 months ago

Lesson

Lesson 5

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

No response

Operating System

Windows

Describe the bug

"Error: cannot estimate gas; transaction may fail or may require manual gas limit". I keep getting this error message whenever i deploy my contract on ganache.

const ethers = require("ethers");
const fs = require("fs-extra");

async function main() {
  //http://127.0.0.1:7545

  const provider = new ethers.providers.JsonRpcProvider(
    "http://127.0.0.1:7545"
  );
  const wallet = new ethers.Wallet(
    "0xb8c18ade1aa094d70c5ad689dff011d6b50bd2472f10ec179d28ba5a0d663862",
    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);
}
main()
  .then(() => Process.exit(0))
  .catch((error) => {
    console.error(error);
    Process.exit(1);
  });
bharathkumar369 commented 2 months ago

same error for me ...

arturantonionunes commented 1 month ago

Same here