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?
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?
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.