In pre 0.5.0 Solidity if you wanted to hash a some set of data you would do keccak(a, b, c). Post 0.5.0 keccak only takes 1 arg and it is suggested to use keccak(abi.encodePacked(a,b,c)) instead

But are the two guaranteed to return the same result? I did some quick testing and it seems like they do, but is this something I can rely on?

1 Answer 1


Yes they do. The easiest way to test it is by using remix and simply switching the complier version for both.

If you take a look at the note in version 0.4.24 of the docs, you will see that this is true and the reason it was switched was to simply be more explicit.

These encoding functions can be used to craft data for function calls without actually calling a function. Furthermore, keccak256(abi.encodePacked(a, b)) is a more explicit way to compute keccak256(a, b), which will be deprecated in future versions.

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.