0

I have a proxy smart contract and I would like to get the name of the called method in the fallback function. Is there a way?

For example, if I call the function getName() (stored in the logic contract), then in the fallback function (of the proxy contract) I would like to get the invoked function name, in this case getName.

contract Proxy {
  function () payable external {
    /* I would like to get here the name of the invoked function */
    _fallback();
  }

  function _fallback() internal {
    _willFallback();
    _delegate(_implementation());
  }


  function _implementation() internal view returns (address);

  function _delegate(address implementation) internal { ... }

  function _willFallback() internal { }
}

Please, check here the full code of the proxy smart contract

2

Full name of the function being called is not passed to the smart contract, but only the first 4 bytes of the hash of function signature. These 4 bytes you can obtain as msg.sig. See documentation for details.

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.