当我尝试编译契约(Contract)时,出现最大调用堆栈大小超出错误,无法解决这个问题。任何见解将不胜感激
错误
RangeError: Maximum call stack size exceeded
at Object.$db [as dynCall_viiiiii] (C:\Users\molli\Desktop\Coding\Udemy\Solidity Course\inbox\node_modules\[4msolc[24m\soljson.js:12:120931)
at invoke_viiiiii (C:\Users\molli\Desktop\Coding\Udemy\Solidity Course\inbox\node_modules\[4msolc[24m\soljson.js:1:1118207)
at Array.pva (C:\Users\molli\Desktop\Coding\Udemy\Solidity Course\inbox\node_modules\[4msolc[24m\soljson.js:13:29030)
at Object.M9a [as dynCall_vi] (C:\Users\molli\Desktop\Coding\Udemy\Solidity Course\inbox\node_modules\[4msolc[24m\soljson.js:12:99033)
at invoke_vi (C:\Users\molli\Desktop\Coding\Udemy\Solidity Course\inbox\node_modules\[4msolc[24m\soljson.js:1:1115011)
at Array.xta (C:\Users\molli\Desktop\Coding\Udemy\Solidity Course\inbox\node_modules\[4msolc[24m\soljson.js:10:704784)
at Object.Dfb [as dynCall_iii] (C:\Users\molli\Desktop\Coding\Udemy\Solidity Course\inbox\node_modules\[4msolc[24m\soljson.js:12:130740)
at invoke_iii (C:\Users\molli\Desktop\Coding\Udemy\Solidity Course\inbox\node_modules\[4msolc[24m\soljson.js:1:1119442)
at Array.vta (C:\Users\molli\Desktop\Coding\Udemy\Solidity Course\inbox\node_modules\[4msolc[24m\soljson.js:10:703080)
at Object.Yfb [as dynCall_iiiiii] (C:\Users\molli\Desktop\Coding\Udemy\Solidity Course\inbox\node_modules\[4msolc[24m\soljson.js:12:131900)
收件箱
pragma solidity ^0.4.17;
contract Inbox {
string public message;
constructor(string initialMessage) public {
message = initialMessage;
}
function setMessage(string newMessage) public {
message = newMessage;
}
}
compile.jsconst path = require('path');
const fs = require('fs');
const solc = require('solc');
const inboxPath = path.resolve(__dirname, 'contracts', 'Inbox.sol');
const source = fs.readFileSync(inboxPath, 'utf8');
module.exports = solc.compile(source, 1).contracts[':Inbox'];
最佳答案
我遇到了同样的问题。
我能够通过降级模块版本来解决它。
我成功时的版本如下。
"ganache-cli": "^6.12.1",
"mocha": "^8.2.1",
"solc": "^0.4.17",
"web3": "^1.0.0-beta.26"