According to https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI, function selector is hashed from function name and list of its arguments put inside ().

For example, with function deposit(uint value), the function selector is Keccak hash of string deposit(uint256)

However, it is not clear in the case of constructor & fallback functions: what should be strings - to be hashed - for below 2 cases?

constructor(address addr) public { }

function () payable public { }


1 Answer 1


The constructor cannot be called. It's only run once: at the deployment of the smart contract.

The fallback function can be called using just call() with no signature, or with any signature that does not belong to any other public or external function of the contract. Hence the name 'fallback'.

  • I see, but then when I looked into the bytecode, i can see the contract looks for this function selector: 7c2efcba. My contract only has 2 functions above, then why it looks for this selector, if neither constructor & fallback functions has signature?
    – user311703
    Aug 20, 2018 at 15:55
  • The 4 bytes of Keccak hash for "()" is 861731d5, which does not match this 7c2efcba function selector signature, so I must misunderstand you?
    – user311703
    Aug 20, 2018 at 15:58
  • How about bytes4(keccak256("")? So, the keccak256 hash of an empty string
    – Henk
    Aug 20, 2018 at 15:59
  • I get back c5d24601 on empty string "". What is your result?
    – user311703
    Aug 20, 2018 at 16:02
  • Not including a dummy selector is bad practice. See my answer here for a better explanation of fallback behavior: ethereum.stackexchange.com/a/123382/36872 Mar 8, 2022 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.