问题描述
在Go中,我正在使用 go-ethereum 从以太坊智能合约中读取数据。我的智能合约是松露的。
我正在尝试根据候选人ID来获取候选人信息。我有一个固定的修饰符,用于检查给定的id是否存在
/**
* Check if candidate exists
*/
modifier candidateExists(uint256 candidateId) {
require(candidates[candidateId].exists,"No Candidate.");
_;
}
如果我通过有效的 candidateId ,一切都会很好。但是,如果候选人不存在并还原,则会发生异常。 以下是ganache-cli控制台中记录的错误
(node:31528) UnhandledPromiseRejectionWarning: Error: nonce generation function Failed or private key is invalid
at Object.t.sign (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:37:75864)
at Object.sign (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:37:64863)
at Object.t.ecsign (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:37:185991)
at e.sign (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:17:104733)
at e.sign (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:10:92594)
at e.t.hash (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:37:243491)
at e.u [as hash] (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:10:89447)
at c.combine (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:2:159323)
at new c (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:2:158990)
at Function.c.fromresults (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:2:160122)
at readyCall (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:17:120626)
(node:31528) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). (rejection id: 26)
(node:31528) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)