Gas cost of views

It seems that currently views are somewhat expensive in terms of gas.

I think that views should be priced similarly or cheaper than lambdas, for the following reasons:

  • views are read-only, while lambdas can mutate storage
  • views that a contract calls on itself don’t have to load or typecheck an additional contract
2 Likes

Michelson lambdas cannot mutate storage, when executing a lambda you cannot access anything more than the argument of the lambda.

Views are more expensive than lambdas because they need to read information about the viewed contract (its storage, its balance, and the view code) and a bit of typechecking (the view code is only typechecked at contract origination and when the view is called). There is certainly room for optimization here but I don’t think we will ever manage to consume as few resources as lambdas.

1 Like

I see. Thanks for the explanation.

1 Like