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

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

I have defined this extremely basic function in order to test if I was being able to execute at least that of my deployed contract. Anyway, when I tried, I got

What does it refers to with those 8 expected arguments ??

Maybe there is another problem that is leading to this one.

Thank you a lot!

1 Like

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

Housekeeping: moving to #support category

Hi @abcoathup , thanks for dedicating your time to try that out, but I believe I didn’t explain my problem properly. I am not having trouble with defining that function on a contract, I have a contract which imports a library and define an instance of another one in order to use its functions and de problem I am having is that I am not being able to execute any of the contract methods.

This same contract, with the same methods, but instead of trying to use a contract instance, I was working with inheritance, works fine. I believe I am doing something wrong with linking libraries or defining the instance that I am not being able to consume it methods. Or I don’t know what can be happening :woman_facepalming:

I am working with:
Truffle v5.0.14 (core: 5.0.14)
Solidity v0.5.0 (solc-js)
Node v10.15.1
Web3.js v1.0.0-beta.37

Thank you!!

So prueba is from a inherited contract or a library?
Libraries might be a bit tricky, But I would expect something like “got 0, expected 2”, not 8 … Is there any chance that you have prueba defined somewhere else with 8 parameters?

Hi @obernardovieira , no, there is no other place I have prueba defined.
Actually, prueba was only a very simple function I added to my contract in order to see if I could execute at least that of my contract, but I couldn’t. prueba is only defined in one contract and it doesn’t use anything of the library nor the contract instance. Anyway, I believe that maybe due to some error on defining the instance on the constructor, or maybe the way I deployed things on the migrations file, is leading everyting to failure but I am not recognizing my mistake.

Do you have some time to have a look at my code and see if maybe yo recognize the error quickly?

All my other functions depends on the library and the contract instance.

Thank you a lot!

@romis the problem is with the version of Truffle you are using, which generates incorrect artifacts when compiling. Please check out the upgrading advise that @abcoathup shared in his response.

1 Like

Ok @spalladino , but while I was working with inheritance I had no problem with using this version and I was being able to execute the functions of my contract through truffle console without trouble. This is why I believe the problem was more on my contract than on truffle version.

I’ll try to update truffle now (I have the problem that I do not have many permissions on this PC so everytime I have to get something installed it’s a headache; this is another reason why I would like to discard that it is not a coding mistake or something like that)

Thank you

1 Like

You can install truffle locally rather than globally, which could make your life easier.