0

If smart contracts can have arrays, and they are persisted in the blockchain, what mechanisms are there to avoid one malicious developer from uploading a smart contract having an array initialized with gigabytes of data?

I am assuming that if I create a contract with a 2GB array, the blockchain size will increase by that amount. Imagine a team of attackers doing that 100 times, and the blockchain starts growing too much.

PedroD
  • 167
  • 6
  • Storage is quite expensive. – Ismael Sep 09 '21 at 05:43
  • Hmm, so this means the bigger the smart contract code, the more you pay? What about when you later call a function that adds some new element to some array in a contract? You pay for the size of that element? How does it work? – PedroD Sep 09 '21 at 09:19

1 Answers1

2

Mainly because storage is expensive.

A large contract require more gas to deploy and it will cost more ether.

Every operation carried by a contract has an associated cost, storing data is one of the most expensive operations. The exact costs are defined in Ethereum Yellow paper and subsequent enhancement proposals.

This question has some calculation about storage costs, since the ether price has increased so the numbers there are outdated, but it may serve as starting point to calculate them today. What is the cost to store 1KB, 10KB, 100KB worth of data into the ethereum blockchain?

Ismael
  • 30,570
  • 21
  • 53
  • 96