6

This is my project and I keep running into Invalid Jump errors whenever trying to call anything other than the Project.getName(). For example, running Project.getAddress(), Project.getAmount(), and Project.deadline() always throw the Invalid Jump. I initially tried to have all of these details log to console with one function, and have broken it down individually to confirm these issues.

I'm running testrpc, and wondering if this could have something to do with gas, despite these functions being constants that wouldn't require any gas. Thanks.

FundingHub.sol

pragma solidity ^0.4.6;

import "Project.sol";

contract FundingHub {

    address public owner;
    address[] public projectAddresses;

    modifier onlyOwner() { if (msg.sender != owner) throw; _; }

    function FundingHub() {
        owner = msg.sender;
    }

    function createProject(string name, uint248 amountToRaise, uint248 deadline) returns (address) {
        address newProject = new Project(name, amountToRaise, deadline);
        projectAddresses.push(newProject);
        return newProject;
    }

    function getProjectAddress(uint i) constant returns (address projectAddress) {
        return projectAddresses[i];
    }

    function killMe() onlyOwner returns (bool successful) {
        suicide(owner);
        return true;
    }
}

Project.sol

pragma solidity ^0.4.6;

contract Project {

    struct projectInfo {
        address projectOwner;
        string name;
        uint248 amountToRaise;
        uint248 deadline;
    }

    projectInfo public info;

    function Project(string name, uint248 amountToRaise, uint248 deadline) {
        info = projectInfo(tx.origin, name, amountToRaise, deadline);
    }

    /*
    function getInfo() public constant returns (address, string, uint248, uint248) {
        return (info.projectOwner, info.name, info.amountToRaise, info.deadline);
    }
    */

    //Only this function works
    function getName() public constant returns (string) {
        return info.name;
    }

    function getOwner() public constant returns (address) {
        return info.projectOwner;
    }

    function getAmount() public constant returns (uint248) {
        return info.amountToRaise;
    }

    function getDeadline() public constant returns (uint248) {
        return info.deadline;
    }
}

Javascript functions

function createProject(name, amountToRaise, deadline) {
    hub.createProject(name, amountToRaise, deadline, {from: account, gas: 3000000}).then(function(txn) {
        return getTransactionReceiptMined(txn);
    })
};

//Doesn't work
function getProjectOwner(i) {
    hub.getProjectAddress(i).then(function(value) {
        console.log(value);
        project = Project.at(value);
        project.getOwner().then(function(value) {
            console.log(value);
        });
    });
}

//Works
function getProjectName(i) {
    hub.getProjectAddress(i).then(function(value) {
        console.log(value);
        project = Project.at(value);
        project.getName().then(function(value) {
            console.log(value);
        });
    });
}

Here's the console output: Console output

  • 1
    Works fine for me in browser solidity. Are you sure it's not an issue with your "hub" returning the wrong address? – Tjaden Hess Jan 30 '17 at 18:59
  • Yes, we need to see your Hub code. – Xavier Leprêtre B9lab Jan 30 '17 at 20:01
  • 1
    To add to @TjadenHess's comment, try examining the address with web3.eth.getCode(). If there's no code, that would explain an invalid jump. (IIRC that's the error it gives in that situation, but I may be wrong.) – Matthew Schmidt Jan 30 '17 at 20:25
  • I added the code and the console output. Yes, it works fine in browser solidity, that's why I don't understand what I'm doing wrong. I also made the javascript functions getProjectAmount and getProjectDeadline, but they return the same error. – user6013 Feb 1 '17 at 2:36
  • Hello, I'm not sure about it, can you give me the following ouput of this: project.getOwner.call().then(function(value) { console.log(value); }); – FrenchieiSverige Feb 1 '17 at 11:21
1

I don't know why, but removing "public" from all the functions in Project.sol solved the problem.

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.