【发布时间】:2021-07-10 13:43:22
【问题描述】:
我是区块链新手。我想调用一个函数来从合约中读取一个变量。 我的合同
bool public isVoting = false;
function getIsVoting() public returns (bool) {
return isVoting;
}
在客户端,我这样打电话
const isVoting = async () => {
const _isVoting = await ElectionInstance.methods
.getIsVoting()
.call()
.then(console.log);
};
然后我得到了错误但不知道为什么:
{
"message": "VM Exception while processing transaction: revert",
"code": -32000,
"data": {
"0xdbe5e039374fdc83fe873f5e55d91f05ec5d19e2e3c88351130c3f3672644e08": {
"error": "revert",
"program_counter": 130,
"return": "0x"
},
"stack": "RuntimeError: VM Exception while processing transaction: revert\n at Function.RuntimeError.fromResults (/tmp/.mount_ganachnMw5dG/resources/static/node/node_modules/ganache-core/lib/utils/runtimeerror.js:94:13)\n at /tmp/.mount_ganachnMw5dG/resources/static/node/node_modules/ganache-core/lib/blockchain_double.js:568:26",
"name": "RuntimeError"
}
}
你能帮我吗,请。我是新人。
【问题讨论】:
标签: solidity web3 truffle contract