Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible to send Mutez along with a call to an on-chain view?

Is it possible for a Tezos smart contract to offer a "Pay per View" on-chain view that will only respond if a certain amount of Mutez is sent with the call, or are on-chain view calls always free?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Tezos on-chain views do not mutate any state (storage, balances, etc.).

But it is possible to have a subscription system, where you can have an on-chain view that verifies if the caller has an active subscription at the current time.

Example:

You create a contract that contains a view A and a big_map(caller: address => expiration_date: timestamp) called subscriptions in the storage.

Then you also have an entrypoint subscribe that adds a given address as a subscriber for a certain period depending on the AMOUNT sent when calling the respective entrypoint.

Now, when the caller calls view A, the view can check if that SENDER is an active subscriber and FAILWITH if it is not.

Or you could also use callback entrypoints, which is an asynchronous approach.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading