Is there a limit for transaction size?

  • Is there a theoretical limit for transaction data size when you send a transaction to Ethereum network?


    Is there a (theoretical) limit for amount of data that a contract can store?

  • Afr

    Afr Correct answer

    5 years ago

    Wow this is such an interesting question! TL;DR: the transaction size limit, at the time of writing, is about 780kB (about 3 million gas). But read on.

    There is no direct or fixed limit neither for transaction sizes nor for block sizes. This is a strength of the Etherem network, it does scale.

    That does not mean that there are no limits. There is the block gas limit of currently 3,141,592 gas which can be spent maximum per block.

    That means, in theory you could create a single transaction which consumes all the gas of a single block.

    Let's try to send 256kB random data with a contract:

    trx with 256kb random data

    That would consume almost 9 million gas, which is not available currently. Mist tries to create the transaction but it will be invalid.

    Let's try to create something close to the gas limit, 44,444 random bytes:

    44k random bytes

    That transaction went through, here is an explorer link. Hash:

    I0207 11:47:14.558908 eth/api.go:946] Tx(0x25e54394ab4e5f17d6e1240c02c1a6c4bb675ef9471f1105b006988f5fe5aec1) to: 0xfcae7970392f510a985a7eaccd3820b7759d65d9
    • Value: 60 Finney (0.06 Ether)
    • Gas: 3131800
    • Gas Price: 50 Gwei (0.00000005 Ether)
    • Gas Used By Transaction: 3031800
    • Actual Transaction Cost: 151.59 Finney (0.15159 Ether)
    • Cumulative Gas Used: 3031800

    So, I just added 44kB to the blockchain in block 967163.

    And now the scaling magic of Ethereum starts to kick in. In block 967164 the network reacts to the high gas consumption and increases the block gas limit to 3,142,967!

    gas limit increased

    So, if there is a continuos request in high gas consumption, the gas limit can be increased by plus/minus 1/1024 which is around 0.09%. See yellow paper equations 40-42.

    In short, limit: yes, at the time of writing about 780kB for a tx full of zero bytes, or 46kB for a tx full of non-zero bytes. Fixed limits (like in Bitcoin): no.

    Update: in Homestead, the block gasLimit is now 4,712,388 (1.5 times PI million) and gas price is 20 GWei. (Methodology above can still be used.)

    I may have missed this, but how does 89kB == 3 million gas?

    Uhm, it's not. Well spotted. It's probably around 40kB. Someone please redo the math, 3 million gas is also outdated. :-)

    You was actually sending 44,444 random bytes. Because you had 178 zero bytes inside, intrinsic gas was 21,000 + (178 * 4) + (44,266 * 68) = 3,031,800. Gas limit is variable (now for example is 500k because of the recent attack to the network) so I think it is not worth to update that value in the answer.

    With this last answer, I'm a bit confused. Is the gasLimit still equal to 3 141 388 gas , or is updated to 4,712,388? Thanks

    It differs. currently around 4,000,000. check for details.

    Since this commit release with geth v1.6.6 will drop transactions over 32kb.

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM