0

Considering the following SmartPy decorators:

  • @sp.utils.view
  • @sp.onchain_view
  • @sp.offchain_view

What are the differences in use between them?

1

1 Answer 1

2
  • @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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.