Lets say, I want to create a smart contract that can receive a record of data per hours, e.g. hourly rates of ETH/EUR. These data would be stored in an array.

What would each transaction cost me and how can I estimate these costs?


1 Answer 1


By pushing a new element in the array, you are setting the storage value from zero to non-zero, therefore it has a cost of 20k gas, plus 5k to update the length member of the array, so it's a total of 25k gas.

So, if your function, say function add_data(uint256[] data) gets in parameter an array of length n, then your gas cost will have a lower bound of 25000*n.

You can find more informations in the yellow paper.

Edit : integrated Jesse's comment.

  • 2
    Pushing into a dynamic array will also incur 5000 gas cost to update the array length field.
    – Jesbus
    Commented Jun 22, 2018 at 20:45
  • Thank you! Will there be also a execution fee every time I call this method?
    – delete
    Commented Jun 23, 2018 at 16:53
  • What do you mean? The execution fee is the gas you will pay. Commented Jun 23, 2018 at 17:11

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