Suppose i have a loop. Here user is a struct of which player is an address.

address[] memory addrs = new address[](n);
for(uint i=0;i<n;i++){
addrs[i] = user.player;
 return addrs;

This is a view function so i know i wont have to pay to run it. Is this going to fail if the value of n increases beyond a point? Im confused about the gas block limit.

1 Answer 1


It depends on how you use it.

If you are calling it from your backend system through a node there is no gas limit as the call never goes inside a block. The call is simply made to the node and the node returns the required information - the blockchain network is not consulted at all. So the only restrictions are your node's throughput and computation power.

However if you call such a function from a non-view smart contract then the regular gas limits and gas payments are in place. So, yes, if your n is too big then you will hit the block gas limit and/or transaction gas limit at some point.

  • ok so if i call it from my frontend ,this wont cause an issue as long as its a view function? Commented Jun 18, 2019 at 6:34
  • 1
    Yes, that is correct Commented Jun 18, 2019 at 6:39

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.