I am using keccak hashing algorithm for converting documents to hashes, the algorithm is producing hashes like: **8185f41244d1a00110cff37b60732228623a82e7da905cac00777029887816ff**

I want to store this hash in a smart contract in bytes32 rather than string (bytes32 consumes less gas then string) but I am getting error message as: Given parameter is not bytes

1 Answer 1


Given parameter is not bytes

You have to add 0x at starting of your hash 8185f41244d1a00110cff37b60732228623a82e7da905cac00777029887816ff like this "0x8185f41244d1a00110cff37b60732228623a82e7da905cac00777029887816ff".

  • But then, they'll no longer be able to store as bytes32 right? because keccak256 already gives a 32 byte hash.
    – anotherDev
    Sep 8, 2021 at 5:17

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.