2

Hey it seems I get a jump error when I try to access any variable not set through a parameter in the constructor. amountRaised is throwing a jump error below as I try to statically set the value.

 contract Project {
 address public fundingHub; 
 address public projectCreator; 
 string public title; 
 string public description;
 uint256 public amountToBeRaised; 
 uint256 public deadline;
 uint256 public amountRaised; 

function Project(address _creator, uint256 _amountToBeRaised, uint256 _deadline, string _title, string _description) {
    if (_amountToBeRaised <= 0) { throw; }
    if (_deadline <= block.timestamp) { throw; }
    fundingHub = msg.sender;  
    projectCreator = _creator;
    title = _title; 
    description = _description; 
    amountToBeRaised = _amountToBeRaised;
    amountRaised = 0; 
    deadline = _deadline; 
}
}

The javascript looks like this

            return thisProject.deadline.call(); 
      }).then(function(_deadline) { 
          console.log("this is the deadline" + _deadline.valueOf());
          return thisProject.amountRaised.call(); 
        }).then(function(_amountRaised) { 
          console.log(_amountRaised.valueOf()); 
          return thisProject.amountToBeRaised.call(); 
        }).then(function(_amountToBeRaised) { 
          console.log(_amountToBeRaised.valueOf());
        });
  }
10
  • Something fishy about the code posted. fundingHub is undefined at fundingHub = msg.sender. Commented Feb 7, 2017 at 23:34
  • Ya sorry I didn't include funding hub...I'll fix it now.
    – ethereal
    Commented Feb 7, 2017 at 23:35
  • It's clear the value is gettable in Browser Solidity. One possibility is your thisProject is out of sync with the deployed contract and the getter function isn't in the deployed compiled code your JS is talking to, in which case the default fallback function will throw. It looks like truffle, so possibly $ truffle migrate --reset and $ truffle build just to get everything nicely aligned. Commented Feb 8, 2017 at 0:10
  • Hmmm thisProject seems to be returning correct values for every other variable. I tried to reset and build, but the error is still there.
    – ethereal
    Commented Feb 9, 2017 at 0:38
  • Not an explanation but possibly a solution. Try defining explicit functions like function getAmountRaised() returns(uint amount) {return amountRaised;}, What you're seeing is consistent with function signatures that don't match even though it appears that they should. Possibly helps with getting on with life to stop relying on the freebie getters "public" provides. Other thought, it shouldn't matter, but thinking about quirks. uint256 = uint, so consider recasting all uint256 as straight uint. Commented Feb 9, 2017 at 2:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.