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!