0

Why isn't delegate call able to run internal functions?

What is the difference between a self directed delegate call and a contract normally calling one of it's internal function?

contract DelegateInternal {

    address public senderOne;
    address public senderTwo;

    function dellyCall() payable returns(uint256) {
        senderOne = msg.sender;
        this.delegatecall(bytes4(sha3('otherFunction()')));
    }

    // Not able to set this variable when this function is made internal
    function otherFunction()
    internal {
           senderTwo = msg.sender;

    }
}
1

The function is internal. That means there's no way to call it directly through a message call, since the signature (bytes4(sha3('otherFunction()')) in this case) isn't in the table of functions. If you must do this, you have to expose a public function, which you can also limit to self-calls if needed by doing require(msg.sender == address(this)).

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.