Will this array "break" when someone calls the public getter function if there are too many entries?

Here is my code:

    ListingLookup[] private allListings;

    struct ListingLookup {
      address borrowerAddress;
      address tokenAddress;
      uint256 tokenId;


Now, because the allListings is a public function, anyone can call and receive a tuple of each ListingLookup structs. Theoretically, this array could have millions of entries.

  • "Now, because the allListings is a public function" - it's actually private in your snippet :)
    – cameel
    Commented Dec 5, 2021 at 1:17

1 Answer 1


There's no hard limit but there's a proposal (pending since 2018) to introduce one: EIP-1985: Sane limits for certain EVM parameters.

  1. buffer size, code size, memory size is a range between 0 and 0xffffffff (2**32 - 1, 4294967295). It affects the following instructions:

    • CALLDATASIZE (0x36),
    • CODESIZE (0x38),
    • EXTCODESIZE (0x3b),
    • RETURNDATASIZE (0x3d),
    • MSIZE (0x59),
    • PC (0x58).

You are however very unlikely to ever hit this limit anyway. You will run out of gas long before then.

Will this array "break" when someone calls the public getter function if there are too many entries?

If the getter was to return the whole array, it would break, in the sense that user's transaction would run out of gas and revert. This is the reason why array getters return only one item at a time. This way it's perfectly safe regardless of how big the array gets.

By the way, depending on how it's meant to be used, it might be more efficient to use a mapping. For example if borrower is unique, you could use it as the key so that it's not stored on chain at all. Anyone who wants to check a particular borrower (identified by an address) already knows this address and can use it for the lookup.

  • "You will run out of gas long before then." - view functions are free of gas fees?
    – Natnael A.
    Commented May 18, 2022 at 16:48
  • They are not free. It's just that a client can simulate their execution off-chain, without actually issuing a transaction. But yeah, in such a simulation you could theoretically reach these limits but it's still 4 gigabytes of data. Even without gas you'll very likely run into some other limitation somewhere along the way - performance, bandwidth, memory of your device, whatever.
    – cameel
    Commented May 19, 2022 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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