Lesson 5: ethers.js Simple Storage - Error: cannot estimate gas #1193
Answered
by
krakxn
BentCrypto
asked this question in
Q&A
-
Hello I am currently using hardhat as my local blockchain. Is there something I am missing since I am using hardhat and not ganache? Following ethers documentation: Link I tried to add gasLimit but it did not help. The code should be same: const ethers = require("ethers");
const fs = require("fs-extra");
gaslimit: "100000000000000";
async function main() {
// compile them in our code
// compile them separately
// http://127.0.0.1:7545
const provider = new ethers.providers.JsonRpcProvider(
"http://127.0.0.1:8545"
);
const wallet = new ethers.Wallet(
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
provider
);
const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8");
const binary = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.bin");
const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
console.log("Deploying, please wait...");
const contract = await contractFactory.deploy();
const transactionReceipt = await contract.deployTransaction.wait(1);
}
main()
.then(() => proecess.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
}); This is a snipet of the error: reason: 'processing response error',
code: 'SERVER_ERROR',
body: '{"jsonrpc":"2.0","id":49,"error":{"code":-32003,"message":"Transaction ran out of gas","data":{"message":"Transaction ran out of gas","data":"0x"}}}',
error: Error: Transaction ran out of gas
at getResult (/root/hh-fcc/ethers-simple-storage-fcc/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:191:21)
at processJsonFunc (/root/hh-fcc/ethers-simple-storage-fcc/node_modules/@ethersproject/web/lib/index.js:348:22)
at /root/hh-fcc/ethers-simple-storage-fcc/node_modules/@ethersproject/web/lib/index.js:280:46
at step (/root/hh-fcc/ethers-simple-storage-fcc/node_modules/@ethersproject/web/lib/index.js:33:23)
at Object.next (/root/hh-fcc/ethers-simple-storage-fcc/node_modules/@ethersproject/web/lib/index.js:14:53)
at fulfilled (/root/hh-fcc/ethers-simple-storage-fcc/node_modules/@ethersproject/web/lib/index.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: -32003,
data: [Object] my package.json: {
"dependencies": {
"ethers": "^5.6.9",
"fs": "^0.0.1-security",
"ganache": "^7.3.2",
"solc": "0.8.7-fixed"
},
"scrips": {
"compile": "yarn solcjs --bin --abi --include-patch node_modules/ --base-path . -0 . SimpleStorage.sol"
},
"devDependencies": {
"hardhat": "^2.10.1"
}
}
|
Beta Was this translation helpful? Give feedback.
Answered by
krakxn
Jul 21, 2022
Replies: 1 comment 6 replies
-
Error here:
Also, add this after the transactionReceipt:
Hope this helps! |
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
BentCrypto
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error here:
Also, add this after the transactionReceipt:
Hope this helps!