Error: missing revert data when deploying Solidity contract with ethers.js and Ganache

Error: missing revert data when deploying Solidity contract with ethers.js and Ganache

Manage alerts

Loading saved threads...

Shuvo · External communityPost link
External question — Ethereum Stack Exchange Author: Shuvo Original post: https://ethereum.stackexchange.com/questions/155508 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I'm having an issue deploying a Solidity smart contract using ethers.js and Ganache. I have a simple contract called SimpleStorage.sol : // SPDX-License-Identifier: MIT pragma solidity 0.8.21; contract SimpleStorage { uint256 favoriteNumber; struct People { uint256 favoriteNumber; string name; } People[] public people; mapping(string => uint256) public nameToFavoriteNumber; function store(uint256 _favoriteNumber) public { favoriteNumber = _favoriteNumber; } function retrieve() public view returns (uint256) { return favoriteNumber; } function addPerson(string memory _name, uint256 _favoriteNumber) public { people.push(People(_favoriteNumber, _name)); nameToFavoriteNumber[_name] = _favoriteNumber; } } I'm compiling the contract using the following command: solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol My deployment script deploy.js is as follows: const ethers = require("ethers"); const fs = require("fs-extra"); async function main() { let provider = new ethers.JsonRpcProvider("http://127.0.0.1:7545"); let wallet = new ethers.Wallet("0x48241723b578d061470e42d6e7cb9625de70b24885ffc989f67f0ee6d78377e4", 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(); When I run node deploy.js , I encounter the following error: Error: missing revert data (action="estimateGas", data=null, reason=null, transaction={ "data": "<data>", "from": "0xd5e4312D240C69c58Cf0098e2Fd7bA3662151925", "to": null }, invocation=null, revert=null, code=CALL_EXCEPTION, version=6.8.0) I replaced actual contract data with <data> for readability. I've verified that my local development blockchain (Ganache) is running, and the wallet has sufficient ETH. I also ensured that the ABI and binary files are correctly generated and used in the deployment script. Any insights into what might be causing this error would be greatly appreciated. Thank you! Node.js version: v18.16.0 ethers.js version: v6.8.0 solc version: v0.8.21 Ganache version: v2.7.1
Quote
Report
Vaibhav Nayak · External communityPost link
External answer — Ethereum Stack Exchange Author: Vaibhav Nayak Original post: https://ethereum.stackexchange.com/a/155929 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I was facing the same issue and fixed it by using a -fixed version of solc In your package.json, try using "dependencies": { "solc": "0.8.14-fixed" }, or "dependencies": { "solc": "0.8.7-fixed" }, I couldn't figure out why this works, as the difference between a fixed version and a non-fixed version isn't stated anywhere. But my guess is that -fixed versions are the stable releases for the command line compilers. Also, make sure you lower the version of your solidity code to less than or equal to the compiler verison you're using Eg: pragma solidity 0.8.14; or pragma solidity 0.8.7;
Quote
Report
CurlyHairedGuy08 · External communityPost link
External answer — Ethereum Stack Exchange Author: CurlyHairedGuy08 Original post: https://ethereum.stackexchange.com/a/161951 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. This problem took like 1;30 hrs of mine. The problem is in the compilation of the code, try to compile the code again like in remix we used to when we made even a single change in the code. Try this: yarn compile and if you haven't yet install yarn install that too. After this run your code and it should probably work. if it doesn't then the code contains other problem(s)
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Ethereum Stack Exchange Author: Shuvo Source score (net votes, not local likes): 0 Original post: https://ethereum.stackexchange.com/questions/155508 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I'm having an issue deploying a Solidity smart contract using ethers.js and Ganache. I have a simple contract called SimpleStorage.sol : // SPDX-License-Identifier: MIT pragma solidity 0.8.21; contract SimpleStorage { uint256 favoriteNumber; struct People { uint256 favoriteNumber; string name; } People[] public people; mapping(string => uint256) public nameToFavoriteNumber; function store(uint256 _favoriteNumber) public { favoriteNumber = _favoriteNumber; } function retrieve() public view returns (uint256) { return favoriteNumber; } function addPerson(string memory _name, uint256 _favoriteNumber) public { people.push(People(_favoriteNumber, _name)); nameToFavoriteNumber[_name] = _favoriteNumber; } } I'm compiling the contract using the following command: solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol My deployment script deploy.js is as follows: const ethers = require("ethers"); const fs = require("fs-extra"); async function main() { let provider = new ethers.JsonRpcProvider("http://127.0.0.1:7545"); let wallet = new ethers.Wallet("0x48241723b578d061470e42d6e7cb9625de70b24885ffc989f67f0ee6d78377e4", 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(); When I run node deploy.js , I encounter the following error: Error: missing revert data (action="estimateGas", data=null, reason=null, transaction={ "data": "<data>", "from": "0xd5e4312D240C69c58Cf0098e2Fd7bA3662151925", "to": null }, invocation=null, revert=null, code=CALL_EXCEPTION, version=6.8.0) I replaced actual contract data with <data> for readability. I've verified that my local development blockchain (Ganache) is running, and the wallet has sufficient ETH. I also ensured that the ABI and binary files are correctly generated and used in the deployment script. Any insights into what might be causing this error would be greatly appreciated. Thank you! Node.js version: v18.16.0 ethers.js version: v6.8.0 solc version: v0.8.21 Ganache version: v2.7.1

Cancel quote

Checking account access…