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... ??
-
This answer gives me the more clearer explanation. Read only function iteration cost– Naveen KumarCommented Mar 3, 2020 at 10:03
Add a comment
|
1 Answer
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.
-
1"if they are being called on-chain" - from a function which is not
pure
orview
! 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