46

The EVM instructions are in the yellow paper, or they are summed up in this answer. But their gas costs are not there. Where can I find a list of all instructions with their associated gas costs?

4
  • Is there an updated table that reflects changes in gas price post EIP158?
    – caslutz
    Commented Sep 20, 2017 at 13:28
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review
    – lungj
    Commented Sep 20, 2017 at 13:59
  • Possible duplicate of What OPCODES are available for the Ethereum EVM? Commented Dec 19, 2017 at 9:18
  • 2
    Probably not a duplicate, as this question is specifically asking about gas costs, which the other question doesn't mention. Commented Dec 19, 2017 at 9:51

3 Answers 3

46

The Yellow Paper is actively maintained and should always be current, and it's not as easy as a table, but the gas costs are there in Appendix G. Fee Schedule and read it with Appendix H.


Historically:

A spreadsheet of opcodes and their gas costs that Ethereum launched with are here.

It has some analysis per How were gas costs chosen for the Ethereum Virtual Machine instructions?

The spreadsheet is titled 1.0 gas costs, so it might not be updated.

edit 2017-12-11: here is the EIP-150 revision of the spreadsheet

Here is a small snippet from it:

ADD .... 3
MUL .... 5
SUB .... 3
DIV .... 5
SDIV ... 5
MOD .... 5
SMOD ... 5
ADDMOD . 8
MULMOD . 8
5
  • This data is (has to be) also available in the source code format in node applications. Commented Jan 18, 2017 at 2:26
  • Thanks, I missed appendix G of the yellowpaper, I thought only appendix H was relevant
    – comodoro
    Commented Jan 18, 2017 at 11:48
  • An updated version of the spreadsheet is here: docs.google.com/spreadsheets/d/…
    – maurelian
    Commented Dec 11, 2017 at 13:46
  • @maurelian Sorry to resurrect this. How are the values for those tagged Formulae calculated? Commented Jun 14, 2018 at 21:45
  • 1
    @Meshugah, The only resources I'm aware of are at the right hand side of that table, or Appendix H of the yellow paper. ethereum.github.io/yellowpaper/paper.pdf
    – maurelian
    Commented Jun 15, 2018 at 21:42
8

If you're looking for such a table for the purpose of golfing down contract gas cost, I'd recommend you bookmark protocol_params.go.

It is good for two reasons:

  1. It is the source of truth. The gas costs specified in that file are what a full node really meters.
  2. It lists the important numbers you really need. For example, the usual gas table doesn't show how storage cost works and they don't tell you much about pre-compiled contracts.

https://github.com/ethereum/go-ethereum/blob/master/params/protocol_params.go

4

There are lots of reference websites for EVM opcodes:

My favorite one is evm.codes:

evm.codes screenshot

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.