So if I understand this correctly, view
function only read data from ethereum and doesn't mutate any state and pure
function doesn't even read data and they are intended for cases like return 1+1;
If this is the case, would they be abused since they don't cost any gas? Like could I just use them for free computation? What happen if I have a infinite loop in a view or pure function?
TLDR: They won't.
Best Answer
Just to add to @Shawn's good answer.
Yes, you can abuse them. But as the
pure
andview
computations are performed only on your own node you would only hurt your own node. You would not hurt the Ethereum network in any way. If you call the function(s) enough, you might even crash your node but it still wouldn't hurt the network in any way.