Charging Gas for reading a view function in a transaction seems odd

,

I just cant get my head around why view functions which are gas free suddenly cost 5k gwei when sandwiched between a state transitioning function which just uses the view function like a web3 call.

When you execute a read only call against a node, the call is executed locally and no transaction is ever sent, so no gas is actually used (in terms of block space). When you put that into a transaction, the read operation is executed as part of the block, taking up gas on the block and requires every node on the network to execute it - so you have to pay for that gas.

1 Like

great thanks for explaining. But i saw for multiple views in the same transaction cost the same as first view. And just discovered eip 2930, after Berlin subsequent views are charged less would be great but 2929 is increasing the sload operation sad.