Skip to main content
Version: Next

view

Views are a form of read-only entrypoints that can be called synchronously, and often are used to read part of the storage.

The decorator is @view and placed just before a function, like the @entry decorator, for example.

type return_type = [list<operation>, int];
// @view
const add = (param: int, storage: int): int => param + storage
// @view
const get_storage = (_: unit, storage: int): int => storage
// @entry
const main = (_: unit, storage: int): return_type =>
[[], storage]

For more information about views, see Views.