1

I put a keccak hashing inside pure function, it works and return me the result.It also works in a for loop. I studied that hashing the data and loop consumes consider amount of gas. Do we need to provide ether for that??. But pure function invocation doesn't go as a transaction right... ??

1

1 Answer 1

0

pure functions do consume gas if they are being called on-chain.

If you are calling the pure function off-chain (e.g. for the frontend of your website), there is no associated cost. If you are calling the pure function on-chain as a part of a transaction, it will consume gas.

3
  • 1
    "if they are being called on-chain" - from a function which is not pure or view! Commented Feb 27, 2020 at 20:00
  • @shane Thats what my question is about.. Why the off-chain call doesn't cost gas?. EVM has to do the computation, Irrespective of the origin right?. Commented Feb 28, 2020 at 5:47
  • @goodvibration It will cost gas if it is not pure or view. That's what my question also. Anyway computation done by EVM is same on both cases. Commented Mar 3, 2020 at 9:49

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.