1

I'm using Truffle Version 2.1 and I'm trying to send test ether to my contract using Testrpc. I run testrpc -u 0 -u 1
And the accounts shows a balance of 99351632199997083360 wei I'm trying to send Ether to a function that contains the payable modifier and returns true (no inner code), and it is returning with a VM jump.

    function fund() payable returns (bool) {

    return true; 
}

And this is the truffle javascript calling the function

var projectBeingFunded = Project.at(projectToFund);
return projectBeingFunded.fund({from: account, amount:amountToGive}); 
}).then(function(txHash) { 
    waitForTransaction(); 
    return web3.eth.getTransactionReceipt(txHash); 
  }).then(function(receipt) { 
        console.log("transaction receipt");
        console.log(receipt.valueOf());
        setStatus("Project successfully funded");
      }).catch(function(e) { 
        console.log(e);
        setStatus("Project funding didn't work");
3

You're submitting an argument called amount, not a payment in Ether.

return projectBeingFunded.fund({from: account, amount:amountToGive});

That would almost be appropriate if the contract function read:

function fund(uint amount) returns(bool) {}

Would actually be:

return projectBeingFunded.fund(amountToGive, {from: account});

But it actually says no arguments are expected, and ETH is expected:

function fund() payable returns (bool) { ...

The unexpected argument is a JUMP. So, try this:

return projectBeingFunded.fund({from: account, value: amountToGive});

Where amountToGive is a uint in Wei and the sender has that much money, as I assume is the case.

Hope it helps.

  • Upon a closer look, I realized there is indeed a problem with the original syntax causing the JUMP but I didn't describe it very well. Corrected to avoid misleading you and others. – Rob Hitchens - B9lab Feb 21 '17 at 19:24
  • what if I want to call this function function fund() payable returns (bool) from inside another contract in solidity? – bturner Sep 26 '17 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.