Skip to main content
corrected spelling and grammar
Source Link

ImI'm trying to create a contract which recievesreceives value to a function called contribute.

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

This is the code I got so far  (all other functions and variables isare 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 or?

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

Im trying to create contract which recieves value to a function called contribute.

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

This is the code I got so far(all other functions and variables is 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 or?

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

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

Source Link
vonGohren
  • 211
  • 2
  • 8

Solidity function receiving value, passing it to another contract function

Im trying to create contract which recieves value to a function called contribute.

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

This is the code I got so far(all other functions and variables is 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 or?

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