Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 2 characters in body
Source Link

contract RemixContract {
    string message;

    constructor() public {
        message = "Hello ZeptoBook";
    }

    function getMessage() public view returns(string memory) {
        return message;
    }

    function setMessage(string memory _message) public {
        require(_message =="hi");
        message = _message;
    }

    function defaultMessage() public pure returns(uint256 num, string memory str){
        return (999, "This is RemixContract Default Message");
    }
}
pragma solidity ^0.5.11;

contract RemixContract {
    string message;

    constructor() public {
        message = "Hello ZeptoBook";
    }

    function getMessage() public view returns(string memory) {
        return message;
    }

    function setMessage(string memory _message) public {
        require(_message =="hi");
        message = _message;
    }

    function defaultMessage() public pure returns(uint256 num, string memory str){
        return (999, "This is RemixContract Default Message");
    }
}

contract RemixContract {
    string message;

    constructor() public {
        message = "Hello ZeptoBook";
    }

    function getMessage() public view returns(string memory) {
        return message;
    }

    function setMessage(string memory _message) public {
        require(_message =="hi");
        message = _message;
    }

    function defaultMessage() public pure returns(uint256 num, string memory str){
        return (999, "This is RemixContract Default Message");
    }
}
pragma solidity ^0.5.11;

contract RemixContract {
    string message;

    constructor() public {
        message = "Hello ZeptoBook";
    }

    function getMessage() public view returns(string memory) {
        return message;
    }

    function setMessage(string memory _message) public {
        require(_message =="hi");
        message = _message;
    }

    function defaultMessage() public pure returns(uint256 num, string memory str){
        return (999, "This is RemixContract Default Message");
    }
}
added 593 characters in body
Source Link

This is the contract code I am trying to run.


contract RemixContract {
    string message;

    constructor() public {
        message = "Hello ZeptoBook";
    }

    function getMessage() public view returns(string memory) {
        return message;
    }

    function setMessage(string memory _message) public {
        require(_message =="hi");
        message = _message;
    }

    function defaultMessage() public pure returns(uint256 num, string memory str){
        return (999, "This is RemixContract Default Message");
    }
}

This is the contract code I am trying to run.


contract RemixContract {
    string message;

    constructor() public {
        message = "Hello ZeptoBook";
    }

    function getMessage() public view returns(string memory) {
        return message;
    }

    function setMessage(string memory _message) public {
        require(_message =="hi");
        message = _message;
    }

    function defaultMessage() public pure returns(uint256 num, string memory str){
        return (999, "This is RemixContract Default Message");
    }
}
deleted 54 characters in body
Source Link
goodvibration
  • 26.2k
  • 5
  • 49
  • 89

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)); }```

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 using Remix IDE for smart contract, Geth for client and React.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

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)); }```

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 using Remix IDE for smart contract, Geth for client and React.js for UI. 

How can I solve these errors. Whenever I call get functions to show outputs, I get these errors:

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));
}
added 2 characters in body
Source Link
Loading
Source Link
Loading