I would like to push large number of items into mapping. Prototype looks like this

mapping (uint => string) ipfs_hashes;
constructor() ERC721("GameItem", "ITM") public {
    ipfs_hashes[0] = "455434544345777";
    ipfs_hashes[1] = "43454d354353445";
    ipfs_hashes[2] = "687678768768786";

But this is just an example. I would like to put 2000 of them, so first I am not sure if contract can be that long and would it break at some point (and at which) and if there is a limit how to achive that. I could make an setter function but then I would need 2000 transaction and this would be very expensive so this is what I want to avoid. Was also thinking that maybe using some sidechain to set state like xDai could work for that. Looking for suggestions and solutions.


Ethereum Storage is still big. It consists of slots and you have 2^256-1 available slots. This means that 2000 items are not even close to the end of the storage...

2^256-1 means that it can store (2^256-1)*32 bytes, since 1 slot = 32 bytes...

Using a setter won't change anything, because you'll still need to store as many items as you're storing now + there'll be additional transaction costs involved...

  • 1
    I don't think this answers the question. OP is asking about the contract size limit, not the storage limit. – Franco Victorio Jan 30 at 3:04
  • Yes, ofcourse I know chain can handle this, question is about contract. – Marko Blazekovic Jan 30 at 8:35
  • I am not sure why you downvoted. if you don't understand what I said, you don't have to click -1. Each contract has storage. so as long as storage can store, the same amount can be stored by contract. – Giorgi Lagidze Jan 30 at 13:47
  • 1
    The amount can be stored but it can't be initialized because the bytecode will eventually be bigger than the contract size limit. That's what the question is about, OP just confirmed it. – Franco Victorio Jan 30 at 14:14
  • Giorgi, you are answering some other question. I know blockchain can store way more then I needed that should be a given and it wouldn't make sense even to ask that as blockchain would be useless if it was that way. I am asking particular question for I need I have. – Marko Blazekovic Jan 30 at 17:03

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.