I'm new to solidity and I'm just testing some examples from tutorials. **The problem is that I can't call get functions although I can call set function.**I'm
The problem is that I can't call get functions although I can call set function.
I'm using Remix IDE for smart contract, Geth for client and ReactReact.js for UI.
How can I solve these errors. Whenever I call get functions to show outputs, I get these errors :
Blockquote
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.
at ABICoder.push../node_modules/web3-eth-abi/lib/index.js.ABICoder.decodeParameters (index.js:286)
at Contract.push../node_modules/web3-eth-contract/lib/index.js.Contract._decodeMethodReturn (index.js:470)
at Method.outputFormatter (index.js:760)
at Method.push../node_modules/web3-core-method/lib/index.js.Method.formatOutput (index.js:147)
at sendTxCallback (index.js:523)
at index.js:293
at XMLHttpRequest.request.onreadystatechange (index.js:98)
Blockquote
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.
at ABICoder.push../node_modules/web3-eth-abi/lib/index.js.ABICoder.decodeParameters (index.js:286)
at Contract.push../node_modules/web3-eth-contract/lib/index.js.Contract._decodeMethodReturn (index.js:470)
at Method.outputFormatter (index.js:760)
at Method.push../node_modules/web3-core-method/lib/index.js.Method.formatOutput (index.js:147)
at sendTxCallback (index.js:523)
at index.js:293
at XMLHttpRequest.request.onreadystatechange (index.js:98)
This is my set function and get function written in App.js:
``` async setData(e) {
e.preventDefault();
const accounts = await web3.eth.getAccounts();
const account = accounts[0];
const gas = await RemixContract.methods
.setMessage(this.state.message)
.estimateGas();
await RemixContract.methods
.setMessage(this.state.message)
.send({ from: account, gas })
.then((res) => console.log(res))
.catch((e) => console.log(e));
}
async getDefaultData() {
await RemixContract.methods
.defaultMessage()
.call()
.then((res) => console.log("response " + res))
.catch((e) => console.log(e));
}
}
async getDefaultData() {
await RemixContract.methods
.defaultMessage()
.call()
.then((res) => console.log("response " + res))
.catch((e) => console.log(e));
}```