Is it possible to write smart contract validator that would check:

  • if UTXO that contains service price information was included so only script can read what is actual price of the service.
  • UTXO with service price information could be only updated by given public key hash
  • validator would validate if user paid the service price

1 Answer 1


This is certainly possible! With the new Vasil HF and the new Babbage era, this will be easier than before. Here is how you can do it using reference inputs.

Mint a NFT with say policy ID and token name abc.ServicePrice. Keep this token at an address that you control, but additionally add a datum to it that contains the service price information. A little disclaimer here, spending this output will destroy the data, so keep that in mind. You can always update the service price by spending it and sending it to the same address with a new datum. Another, more involved option is to keep this NFT + datum at a script address that could mandate more constraints. Possible logical constraints could be that you want to make sure that this NFT never moves to another address. But since you control the price, this is not a necessity.

Now you create a script that provides the service and needs the price. In it, you mandate that the script only validates if the token abc.ServicePrice is in the transaction as a reference input. Given that this holds, you can retrieve the datum of that reference input and thus the service price. Also, make the script fail if the service price is not paid to you.

Cool construction of a proxy contract!

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.