1

Is it possible for a 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?

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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