'throw new Error 'Returned values aren't valid, did it run Out of Gas?
I am getting this error:
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.
const Web3 = require("web3");
const MyContract = require("./build/contracts/MyContract.json");
const init = async () => {
const web3 = new Web3("http://127.0.0.1:9545");
const id = await web3.eth.net.getId();
const deployedNetwork = MyContract.networks[id];
const contract = new web3.eth.Contract(
MyContract.abi,
deployedNetwork.address
);
const addresses = await web3.eth.getAccounts();
await contract.methods.setData(10).send({
from: addresses[0]
});
const data = await contract.methods.getData().call();
console.log(data)
};
init();
Solution 1:[1]
Can be many things, but there are two causes most common.
- Very if you are using abi and a contract address correct.
- Very if you are selected the correct network, for exempo, if your contract is on Rinkeby you can selected Rinkeby or if your contract is on Mainnet select the Mainnet.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jeftar Mascarenhas |