5

What happens if I craft an EVM binary such that the ABI sees two matching method IDs, and try to deploy the contract? Is it a valid transaction?

1

1 Answer 1

5

Function selectors are a Solidity concept. The code it emits basically does a switch statement and jumps to the right function.

If you have a collision of function selectors, the Solidity compiler raises an error. If you skip the Solidity compiler and write your own bytecode that makes use of function selectors, you'll just have to decide what to do yourself. (You can make the code do whatever you want.)

The rest of the system does not care about function selectors or how your contract behaves in those cases.

2
  • So method resolution is done by the contract code? Not the EMV?
    – azavalla
    Commented Apr 19, 2018 at 17:10
  • That's correct.
    – user19510
    Commented Apr 19, 2018 at 17:11

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.