current position:Home>Error: returned values are't valid, did it run out of gas?

Error: returned values are't valid, did it run out of gas?

2022-02-03 20:57:46 Q & A of Denglian community

use [email protected] and [email protected] Deploy a simple contract to get the value of the state variable . An error is reported when obtaining the value of the state variable . I've been looking for it for days, but I haven't found the reason . Thank you for your help . Ethereum novice , Thank you very much for your help in solving doubts and reporting mistakes err: Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced. Other error reporting processes are as follows at ABICoder.decodeParameters (/home/2/node_modules/web3-eth-abi/src/index.js:239:15)at Contract._decodeMethodReturn (/home/2/node_modules/web3-eth-contract/src/index.js:557:22)at Method.outputFormatter (/home/2/node_modules/web3-eth-contract/src/index.js:910:46)at Method.formatOutput (/home/2/node_modules/web3-core-method/src/index.js:167:54)at sendTxCallback (/home/2/node_modules/web3-core-method/src/index.js:596:33)at /home/2/node_modules/web3-core-requestmanager/src/index.js:147:9at XMLHttpRequest.request.onreadystatechange (/home/2/node_modules/web3-providers-http/src/index.js:110:13)at XMLHttpRequestEventTarget.dispatchEvent (/home/2/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)at XMLHttpRequest._setReadyState (/home/2/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)at XMLHttpRequest._onHttpResponseEnd (/home/2/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)at IncomingMessage. (/home/2/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)at IncomingMessage.emit (events.js:323:22)at endReadableNT (_stream_readable.js:1204:12)at processTicksAndRejections (internal/process/task_queues.js:84:21),val: undefined

The code is simple : stay infura utilize ropsten Test network sol:

pragma solidity ^0.5.0;contract MyContract {    string value;    constructor() public {        value = "myValue";    }    function get() public view returns(string memory ) {        return value;    }    function set(string memory _value) public {        value = _value;    }}


const Web3 = require('web3')const web3 = new Web3('')const contractAddress = '0x30951343d6d80d2c94897f1a81c53cc030aef879'const contractABI = ```[    {        "constant": false,        "inputs": [            {                "internalType": "string",                "name": "_value",                "type": "string"            }        ],        "name": "set",        "outputs": [],        "payable": false,        "stateMutability": "nonpayable",        "type": "function"    },    {        "constant": true,        "inputs": [],        "name": "get",        "outputs": [            {                "internalType": "string",                "name": "",                "type": "string"            }        ],        "payable": false,        "stateMutability": "view",        "type": "function"    },    {        "inputs": [],        "payable": false,        "stateMutability": "nonpayable",        "type": "constructor"    }]const contract = new web3.eth.Contract(contractABI, contractAddress)contract.methods.get().call((err, val) => {  console.log({ err, val })})

Take the answer 1:

I wrote it again ,ropsten No mistake

Other answers 1:

Other answers 2:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.

Random recommended