Skip to main content

View

A view is a function that can be called by other contracts.

Like functions, a view is read only, that is it does not modify the contract's storage nor does generate operations.

It is declared with the view keyword followed by the view's identifier and arguments. It returns a value whose type is declared after :.

For example:

view affine(x : rational) : rational {
return (2 * x + 3)
}

The view's body use the return keyword to return the result.

A view is called with the call_view builtin.