Inconsistency between function definition and error message when trying to execute it through truffle console

Hi @romis

I deployed the following, though please note I changed the function to view so it does a call rather than a transaction and I could interact with it using truffle console.

Sample.sol smart contract

pragma solidity ^0.4.23;

contract Sample {

    function prueba() public view returns (uint256 retorno){
        retorno = 8989;
        return retorno;
    }
}

2_deploy.js:

const Sample = artifacts.require("Sample");

module.exports = function(deployer) {
  deployer.deploy(Sample);
};

truffle console

truffle(development)> sample = await Sample.deployed()
truffle(development)> (await sample.prueba()).toString()
'8989'

Can you advise versions of:

  • truffle
  • node

I used:

  • truffle 5.0.21
  • node 10.16.0

I suspect that you could be using an older version of truffle