Hey I think this may be a problem with the javascript side or Truffle, but the following function is returning true when I call it, but when I send a transaction to it, the test ether seems to disappear.

 uint public amountRaised; 
 mapping (address => uint) contributionLedger;
 address[] public contributors;

 function fund() payable returns (bool) {
        if (msg.value == 0) { throw; }
        if (block.timestamp > deadline) { throw; }
        if (amountRaised > amountToBeRaised) { throw; }
        if (contributionLedger[msg.sender] == 0) { 
        amountRaised += msg.value;
        contributionLedger[msg.sender] += msg.value; 
        return true; 
  • It should be accumulating in the contract's balance. How are you checking it? Feb 19 '17 at 23:29
  • I'm checking the getter for amountRaised, which returns 0
    – ethereal
    Feb 20 '17 at 16:25

There is a missing ; in your third line that would prevent compile. Also had to add some details to get it compile and work. With those edits, it works fine. Possibly the way you check amountRaised.

Remix pic so you can see it working.

Hope it helps.

enter image description here

  • Ok thanks Rob, I just missed the semicolon while copying it over..... thats good to know the function works! I still seem to be having issues calling it with Truffle and Testrpc though. I'm getting a VM Jump error...I think I will abandon Truffle.
    – ethereal
    Feb 20 '17 at 22:41
  • I've been using truffle 2.1.0 and it's really good for getting past the tedium. Truffle 3.x is quite new and I'm just starting to familiarize myself with it and the issues people are reporting. Don't forget it's a callback, or promise In truffle. Would be something like contract.amountRaised.call().then(function(amount) {} ... Feb 20 '17 at 23:27

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.