gpt4 book ai didi

javascript - 编译 Solidity 错误 - RangeError : Maximum call stack size exceeded

转载 作者:行者123 更新时间:2023-12-03 20:39:00 31 4
gpt4 key购买 nike

我关注 this Stephen Grider 的类(class),学习 Solidity。
我无法使用 compile.js 来编译solidity。我正在使用 node.js 版本 12.18.3。 solc 版本 0.4.25 和 npm 版本 6.14.16。
编译.js代码:

const 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'];

Course
收件箱.sol 代码:

pragma solidity ^0.4.25;

contract Inbox {
string public message;

function Inbox(string initialMessage) public {
message = initialMessage;
}

function setMessage(string newMessage) public {
message = newMessage;
}
}

这是完整的错误:

RangeError: Maximum call stack size exceeded
at Object.$db [as dynCall_viiiiii] (C:\Users\iluka\Desktop\Solidity\Inbox\no
de_modules\←[4msolc←[24m\soljson.js:12:120931)
at invoke_viiiiii (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4mso
lc←[24m\soljson.js:1:1118207)
at Array.pva (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4msolc←[2
4m\soljson.js:13:29030)
at Object.M9a [as dynCall_vi] (C:\Users\iluka\Desktop\Solidity\Inbox\node_mo
dules\←[4msolc←[24m\soljson.js:12:99033)
at invoke_vi (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4msolc←[2
4m\soljson.js:1:1115011)
at Array.xta (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4msolc←[2
4m\soljson.js:10:704784)
at Object.Dfb [as dynCall_iii] (C:\Users\iluka\Desktop\Solidity\Inbox\node_m
odules\←[4msolc←[24m\soljson.js:12:130740)
at invoke_iii (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4msolc←[
24m\soljson.js:1:1119442)
at Array.vta (C:\Users\iluka\Desktop\Solidity\Inbox\node_modules\←[4msolc←[2
4m\soljson.js:10:703080)
at Object.Yfb [as dynCall_iiiiii] (C:\Users\iluka\Desktop\Solidity\Inbox\nod
e_modules\←[4msolc←[24m\soljson.js:12:131900)

最佳答案

考虑在 package.json 文件中降级模块版本,然后使用 npm install。上面的代码片段在以下依赖项下工作正常

  "dependencies": {
"ganache-cli": "^6.12.2",
"mocha": "^8.4.0",
"solc": "^0.4.26",
"web3": "^1.0.0-beta.26"
}

关于javascript - 编译 Solidity 错误 - RangeError : Maximum call stack size exceeded,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67782232/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com