<p>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.</p>
<p>Mint a NFT with say policy ID and token name <code>abc.ServicePrice</code>. 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.</p>
<p>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 <code>abc.ServicePrice</code> 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.</p>
<p>Cool construction of a proxy contract!</p>

CC BY-SA 4.0
2022-08-11T06:46:23.857Z
2022-08-11T06:46:23.857Z
Fermat
<p>Is it possible to write smart contract validator that would check:</p>
<ul>
<li>if UTXO that contains service price information was included so only script can read what is actual price of the service.</li>
<li>UTXO with service price information could be only updated by given public key hash</li>
<li>validator would validate if user paid the service price</li>
</ul>

<plutus><plutus-pioneer-program><plutus-playground><utxo>
Smart contract configuration
# Smart contract configuration

(Asked by: username_0 on 2022-02-01)

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

**Tags:** plutus, plutus-pioneer-program, plutus-playground, utxo

---

## 1 answers

### Answer by username_1 on 2022-08-11. Score: 0

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!


---

