1

I have a public function which takes in a uint256[] memory input argument. I tried passing it an array of ~1000 elements in an array and it constantly failed with failing gas estimation. But, it works with ~150 elements - i'm continuing to test with higher length arrays but was wondering if there's a limit specified somewhere?

1 Answer 1

1

I don't think there's an explicit limit for an array size in a parameter. But the limit is caused by hitting the a gas limit.

You need to pay gas for each byte of data you input in your transaction, and per every operation the transaction triggers. If the combination of these two is too high, the transaction is reverted because it runs out of gas. Your wallet is also smart enough that it detects this failure and doesn't even let you execute the transaction.

If you have defined an explicit gas limit for transactions, you can make that higher. Otherwise you're simply hitting the network's block gas limit, which depends on the used network.

Furthermore, there's the possibility that your code simply reverts for some code-related reason.

1
  • 1
    For the same of completeness I'd add that there's a draft EIP that would impose a hard limit on the size or calldata: EIP-1985. The limit would still be pretty high though (~4GB) so you are not likely to hit it before you run out of gas.
    – cameel
    Aug 28, 2021 at 23:53

Your Answer

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

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