E.g. a function that just returns huge struct data. Is there any limit in data so that calling this function will not be possible?

pragma solidity ^0.4.13;

contract Project
    struct Person {
        address addr;
        uint funds;
    Person[] people;
    function getPeople(uint[] indexes)
        returns (address[], uint[])
        address[] memory addrs = new address[](indexes.length);
        uint[]    memory funds = new uint[](indexes.length);
        for (uint i = 0; i < indexes.length; i++) {
            Person storage person = people[indexes[i]];
            addrs[i] = person.addr;
            funds[i] = person.funds;
        return (addrs, funds);

code sorce

If I stored 1000000000000... Person, can I return them with getPeople()?

Edit: Changed function to view, avoiding confusions.

  • 1
    Your function should be declared view, and then there shouldn't be any gas cost involved. All the data is (already) on the blockchain, you are not changing anything, so there's no mining involved, hence no subsequent gas cost. Commented Sep 12, 2018 at 10:30
  • @goodvibration to clarify, my questions was if a function which can not be called by a contract since it would exceed the gas limit can still be viewed?
    – Senju
    Commented Sep 13, 2018 at 19:18
  • 1
    In 2022, it still seems that Geth will provide 50M gas. If you need higher, you need to specify.
    – eth
    Commented Jan 16, 2022 at 23:40

2 Answers 2


If you are calling this from an external account (using web3 or similar) then there is no gas cost associated because the function is view and is resolved in the node you are connected to. On the other side if this is called from a contract, then there would be gas cost asssociated with it and the gaslimit is the same than for any other transaction.

As for the amount you point out, storing this amount of data is impractical and super expensive. reading this form the node will be feasible, but from a contract it wouldn't work.

Hope this helps

  • Isn't there issue due to internal memory of the evm ?
    – Gopal ojha
    Commented Sep 12, 2018 at 9:08
  • I missed the part where the OP said that he wants to store and read a large amount of data. The amount he suggests is impractical as this is too expensive.
    – Jaime
    Commented Sep 12, 2018 at 9:14
  • 2
    You missed that because the entire question is confused and unclear. First, the question title asks "Is there a gas limit for view requests", implying that the question is about view functions, which is more or less what you have referred to. Then, in the question body, the function itself isn't declared view, which doesn't really "align" with the title. Then, a deeper look shows that it can be declared view, making your answer once again relevant. And last, the question all of the sudden changes from data-reading to data-changing, and so your answer becomes once again incomplete. Commented Sep 12, 2018 at 10:35
  • Updated the function using view
    – Senju
    Commented Sep 13, 2018 at 19:11

Definitively yes, it consumes gas!

It does not consume gas when called from a local node or Web3 ONLY.

The execution of the code you wrote consumes gas on the EVM, even if it does not modify the blockchain but the local memory only.

If this were not the case, any EVM view function should be able to go in a infinite loop without being stopped in the eternity...

For instance your for loop consumes gas: watch at yellow paper tables.

On the other side if your JavaScript application running on your local Pc access public variables, it do not consumes gas in reading the blockchain (by Web3 acces for instance).

  • Just to confirm. Is your 'definitively yes' related to the first or second questions?
    – Senju
    Commented Oct 4, 2018 at 10:18
  • In my opinion this answer is misleading - it's not "definitively yes" as calling view functions will not cost gas when called from an external account. This is all explained properly in the other answer. Commented Oct 4, 2018 at 10:25
  • Definitively yes it consumes gas, but if called by local node or Web3.
    – Rick Park
    Commented Oct 4, 2018 at 11:57
  • I add for Lauri Peltonen: the question is clear, read the title. The answer “definitively yes” is the right answer to that title. Of course.
    – Rick Park
    Commented Oct 4, 2018 at 14:36
  • But what would be the actual limit of data quantity that the node would be able to send to a client? Is that limited by the same gas limit in the genesis block? Is that limited on the node itself?
    – shellwhale
    Commented Jun 19, 2021 at 23: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.