I am making a contract with a front-end made with JS, I studied myself how to make it work calling the functions with or without variables. But I don't know how to get the return value. I would appreciate your help. On Remix it works fine. The solidity function of the issue

function Recompte()  public returns (uint _votes, string memory _info){
    if (estat == true) {
        return (votes,"Poll stills on");

        for (uint i = 0; i<candidats.length; i++){
            if (candidats[i].votes > votes){
                votes = candidats[i].votes;
                idwinner = candidats[i].id;
    return (idwinner, candidats[idwinner].name);

Code of JavaScript for this function for the moment

    var val = 0;

    val = parseInt($("#value_input").val());
    web3.eth.getAccounts().then(function(accounts) {
        var acc = accounts[0];
        return contract.methods.Recompte().send({from: acc});

Sorry for making a mess, enters don't work and I don't know why JavaScript isn't inserted well.

Thank you for your time

  • Wasn't what I asked – Zerohmaru Mar 20 at 18:11
  • It is exactly what you asked for. Your code is calling a non-constant function Recompte() and you want the values returned. – Ismael Mar 20 at 18:15
  • 1
    @Zerohmaru: Please read the answer in the link suggested above. The value returned from a non-constant function is available only on-chain (i.e., when called from some other contract-function). When called off-chain (e.g., a web3.js script, a web3.py script, etc), all you get is a receipt of the transaction, because the transaction is executed asynchronously (i.e., takes time for the nodes on the network to add it to the blockchain). A thousand similar questions have been asked here before, hence the suggested link. – goodvibration Mar 20 at 18:21

Browse other questions tagged or ask your own question.