Skip to main content

Solidity function receiving value, passing it to another contract function

I'm trying to create a contract which receives value to a function called contribute.

Then I shall call another contract function with value. I wonder how this is done, it's not very clear.

This is the code I got so far (all other functions and variables are left out for simplicity):

contract Hub {
    function contribute(address _address) payable {
       Project project = Project(_address);
       project.fund.value(msg.value)();
    }
}

contract Project {
    function fund(address sender) payable {
       amount += msg.value;
       contributors[sender] = msg.value;
    }
}

This gives me invalid opcode for some reason. What might be wrong? Am I trying to do it wrong?

Opcode stack is here: https://gist.github.com/vongohren/160b61e5fd2b6c0c85fb8829aed9b3b2

vonGohren
  • 211
  • 2
  • 8