Is it possible to have a mapping in Solidity with a hash as key?

For example:

mapping (hash => uint) hashToInt;

If not, is there any way to group some information and put it as a key of a mapping?

1 Answer 1


Yes, hash was an old type that's been replaced with bytes32. You can call keccak256(data1, data2, ...) and use that as a key.

Prior discussion on hash.


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.