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.

2
  • Storage is quite expensive.
    – Ismael
    Sep 9 at 5: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 9 at 9:19
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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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