Delegatecall

內部函式的 DelegateCall 不儲存變數

  • February 13, 2019

為什麼委託呼叫不能執行內部函式?

自我導向的委託呼叫和通常呼叫其內部函式之一的合約有什麼區別?

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;

   }
}

函式是內部的。這意味著無法通過消息呼叫直接呼叫它,因為簽名(bytes4(sha3('otherFunction()'))在這種情況下)不在函式表中。如果你必須這樣做,你必須公開一個公共函式,如果需要,你也可以通過做require(msg.sender == address(this)).

引用自:https://ethereum.stackexchange.com/questions/67018