AFAIK there are 3 hash functions to choose from in solidity (
ripemd). sha3 is native while the others use precompiled contracts.
Which one of these is cheapest (in terms of gas)?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
keccak256 (new alias for
sha3) is cheapest.
Source: Yellow Paper
Appendix G mentions the gas cost of
Appendix E has the costs for the others.
sha256 (SHA2-256) costs:
ripemd is even more expensive: