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 Commented Jan 31, 2018 at 1:51

2 Answers 2

12

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. Commented 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 you have read our privacy policy.

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