The question is in the title :). Trying to understand why there is both an opcode and pre-compiled contract for SHA256. To execute the computation, would people canonically "CALL" into the pre-compiled contract or just use the SHA256 opcode directly?

1 Answer 1


As far as I'm aware there is no SHA256 opcode. I tried finding one but couldn't find - not listed at least in, for example, this list: https://github.com/crytic/evm-opcodes

Maybe you're mixing it up with sha3 (keccak256)? It's a different algorithm.

So if you want to use SHA256 you need to call the precompiled contract. But if you're worried about gas costs there are cheaper alternatives around as well, quick googling found at least this: Gas cost of a sha256 hash

  • Follow-up question: what is the reason for implementing an operation as an opcode vs as a precompiled contract? The predicted frequency of uses only? Or is there a fundamental reason why sha256 couldn't be implemented as an opcode?
    – samlaf
    Dec 1, 2022 at 7:48
  • please post a new question if you have a new question Dec 1, 2022 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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