[Ethereum] Sending test ether on Testrpc

soliditytestingtestrpctruffle

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");

Best Answer

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.

Related Topic