1

在 Go 中,我使用go-ethereum从以太坊智能合约中读取数据。我的智能合约是用松露维护的。

我正在尝试根据候选人 ID 获取候选人信息。我在solidity中有一个修饰符,用于检查给定的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.


4

0 回答 0