当我从我的solidity智能合约中调用一个view only函数时,在web3js中遇到一个错误。奇怪的是,它可以在本地testnet上运行(通过Ganache运行),但是当我将合约部署到ropsten测试网络时,fall函数失败,并出现以下错误:
Uncaught (in promise) Error: Returned values aren't valid, did it run Out of Gas?
at i.decodeParameters (web3.min.js:22508)
at l.o._decodeMethodReturn (web3.min.js:29647)
at A.outputFormatter (web3.min.js:29766)
at A.formatOutput (web3.min.js:16439)
at u (web3.min.js:16615)
at web3.min.js:17813
at inpage.js:1
at inpage.js:1
at i (inpage.js:1)
at inpage.js:1
at inpage.js:1
at c (inpage.js:1)
at inpage.js:1
at We (inpage.js:1)
at Object.<anonymous> (inpage.js:1)
at e.exports._runReturnHandlersUp (inpage.js:1)
at inpage.js:1
at n (inpage.js:1)
at i (inpage.js:1)
at inpage.js:1
at inpage.js:1
at n (inpage.js:1)
at i (inpage.js:1)
at inpage.js:1
at inpage.js:1
at inpage.js:1
at inpage.js:1
at c (inpage.js:1)
at u (inpage.js:1)
at inpage.js:1
at inpage.js:1
at a (inpage.js:1)
我还得到了另一个错误,以下说明:
Denying load of chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/sourcemaps/inpage.js.map. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.
可能相关也可能无关。
导致错误的前端代码是:
for (var i = 0; i < userDetails[0]; i++) {
console.log(i)
var contractAddress = await trsContract.methods.getUserContract(i).call()
console.log(contractAddress)
contractAddresses.push(contractAddress)
}
我正在使用以下依赖项
"@material-ui/core": "^4.5.2",
"material-ui": "^0.20.2",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.2.0",
"react-spinners": "^0.6.1",
"validator": "^12.0.0",
"web3": "^1.2.2"
1条答案
按热度按时间v8wbuo2f1#
您是否使用正确的合同地址启动trsContract?
如果设置了错误的地址,它将返回错误。