Considering the following SmartPy decorators:
@sp.utils.view
@sp.onchain_view
@sp.offchain_view
What are the differences in use between them?
Tezos Stack Exchange is a question and answer site for users, experts, and developers of the Tezos blockchain project. It only takes a minute to sign up.
Sign up to join this community@sp.utils.view
: An old helper that simplifies the creation of an entrypoint that callback a contract with a value. Do not use it except if you know what you are doing.@sp.onchain_view
: an on-chain view is a piece of code that can be called by contracts and also off-chain tools. It is read-only and returns a result.@sp.offchain_view
: isn't uploaded anywhere on the chain. Its code is added to the metadata JSON file/tab generated by SmartPy and must uploaded somewhere and then linked in the metadata bigmap. It can be linked into the metadata. It can be executed by off-chain tools only and is read-only. It returns a result.