13

It should not be hard to find collision. There is only 4 294 967 296 possible signatures.

1
  • 3
    Here's a collision: contract a {int public gsf;int public tgeo;} it won't compile Jan 31, 2018 at 1:51

2 Answers 2

13

The function signatures need to be unique only within a contract. The Solidity compiler will detect and prevent collisions if they are not unique in this case. If you have fewer than 2^16 functions in your contract, collisions are unlikely to happen by chance.

There was a Reddit thread about this recently, but it seems a bit contrived to me and not a problem in practice.

1
  • Having two identical function hash in the same contract means two functions with the same signature and that is impossible and compiler would detect it. Aug 5, 2017 at 20:35
2

If two functions have exact same signature in within your contract, the program will not run as during function call, the flow would be confused in which function it has to go. Function overloading is possible but the signature of each function should be unique within the contract. Different contracts can have same function signature. Refer this for function signatures.

0

Your Answer

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

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