Is it bad practice to return dynamic arrays in case they grow beyond the block gas limit? If the array grew too large you would no longer be allows to access this array? The other alternative I see is to return the length of the array and then send many queries to retrieve each member in the list.

1 Answer 1


Yes, it is generally a bad practice. If this array could grow without control, any function looping through it will run out of gas and throw.

You'd still be able to access a particular element by its index, by doing array[1000000], but looping through it would surely fail.

You could implement a function that receives a start + offset parameters to do a sort of pagination, or you could do as you say, using the array's length, do n calls to get each element.

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.