This question already has an answer here:

What is the correct algorithm to calculate gas limit for transaction with data in Ethereum?

marked as duplicate by Achala Dissanayake, Ismael, Muhammad Altabba, Luiz Soares, manuhalo Feb 15 '18 at 15:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    It's not a duplicate! The attached QA has nothing to do with arbitrary data cost estimation. – Slava Fomin II Feb 16 '18 at 14:33

According to Ethereum Yellow Paper, in order to calculate gas limit for transaction with non-zero data you will need to use the following formula:

gasLimit = Gtransaction + Gtxdatanonzero × dataByteLength


Gtransaction = 21000 gas

Gtxdatanonzero = 68 gas

dataByteLength — your data size in bytes

So, the final formula would look like this:

gasLimit = 21000 + 68 * dataByteLength.

If your data has 10 bytes, the gas limit would be:

gasLimit = 21000 + 68 * 10 = 21000 + 680 = 21680

  • will it be different if I'm sending to a contract address? – Tristan Tzara Jul 19 at 7:43

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