0

When I try to execute in console

node compile.js

I get this error.

RangeError: Maximum call stack size exceeded when try Compilation in Solidity

Invox.sol:

pragma solidity  ^0.4.25;

contract Invox {
    string public message;

    function Invox (string initialmessage) public {
        message = initialmessage;
    }
    function setMessage(string _message) public {
        message = _message;  
    }
}

compile.js:

const path = require('path');
const fs = require('fs');
const solc = require('solc');
const invoxPath = path.resolve(__dirname, 'contracts', 'invox.sol');
const source = fs.readFileSync(invoxPath, 'utf8');
//We have replaced the following line, but the issue persists
module.compile = solc.compile(source, 1).contracts[':Invox'];
//console.log(solc.compile(source, 1));

package.json:

{
  "name": "invox",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "solc": "^0.4.25"
  }
}
5
  • Can you share your package.json? most likely it is a solc version issue. Commented Oct 10, 2019 at 4:20
  • Just do it!! Thanks for answering Commented Oct 10, 2019 at 15:08
  • @IftifarTaz I have installed version 6.10.2 of solc but still giving the same error I am blocked Commented Oct 14, 2019 at 10:59
  • With the code provided it compiles for me. and always use solc version same as pragma solidity in contract. Commented Oct 14, 2019 at 12:58
  • I got too excited. This did not work either. I still don't really know what the problem is. Commented Oct 15, 2019 at 11:54

2 Answers 2

3

npm install --save [email protected]

run the above command and change the solidity version in your invox.sol

pragma solidity ^0.4.25; -> pragma solidity ^0.4.17;

Sign up to request clarification or add additional context in comments.

2 Comments

Oh great it worked! ... Now it's time to fix the error of installing npm install --save web3@^1.0.0-beta.36 There is no way to find a solution.
I have had errors in the installation in windows but it seems to work. forget the above then. A million thanks.
0

Maybe your nodejs version is too high.

I met this problem when node v12.16.0 is used. However, when I switched it to v8.5.0, everything works well.

2 Comments

Thanks for answare me. My version is "solc": "^0.4.25"... You can see that in JSON file.
We have replaced the following line, but the issue persists: module.compile = solc.compile(source, 1).contracts[':Invox']

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.