3

Since query or constant functions are just executed on single node there is no dependency on gas or gas limit. I am performing Quicksort in query/constant method. EVM can sort an array of length up to 50000. The function returns zero if array size increases.

1 Answer 1

-1

Every operation executed by the blockchain costs gas. The theoretical max number of operations that can be executed is thus the max gas/block.

Otherwise, the whole blockchain could be spammed (and eventually killed) with while(true){} function calls.

Constant functions (the ones that are not modifying the state), can be executed on demand, on your local node and then it wouldn't cost any gas. But if you call that function from a transaction, it will cost gas.

6
  • Every operation executed by the blockchain costs gas. The theoretical max number of operations that can be executed is thus the max gas/block. This is not true for constant functions.
    – Subhod I
    Feb 15, 2018 at 14:04
  • I gave you the reason why this is true. I posted you the link to another answer that supports my affirmation. Here's a reference to the official solidity documentation where you can see that adding 2 numbers consumes 3 gas. What makes you think that everybody's lying you and that in fact they don't cost gas? Feb 15, 2018 at 14:13
  • Function calls via the RPC method eth_call allows free reading of contract data. Most libraries that use RPC have functionality like this. See github.com/ethereum/wiki/wiki/JSON-RPC#eth_call. It's read only, so of course any state changes it causes wont be permanent.
    – natewelch_
    Feb 15, 2018 at 15:42
  • @flygoing, you're right and that's what I meant by functions executed on a local node. However, if such a function is called from a smart contract function, which is not called through RPC, but it's executed by the blockchain, then it costs gas. Feb 15, 2018 at 15:57
  • 1
    Right, but that clearly is not what OP was asking about, and you're just being pedantic to be pedantic.
    – natewelch_
    Feb 15, 2018 at 15:58

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.