4

I want to use an NFT as a form of authentication for a Plutus contract.

I know I can attach the NFT in the Datum when constructing the transaction and return the NFT in the output however I am worried this will "lock" the NFT such that the user can only submit a single transaction.

My use case is an invite mechanism that only holders of a specific NFT are able to execute, this endpoint will generate a UTXO that is used as a required input into the actual signup endpoint.

enter image description here

So based on this example, can the invite endpoint read the presence of the AM NFT in the redeemers wallet without it being sent into the transaction?

  • Note I am new to a lot of this so feel free to tell me I have got this wrong.

1 Answer 1

3

I'd check out using mustSpendPubKeyOutput in your off-chain transaction constraints.

To answer your question directly:

Can a smart contract read the presence of an NFT in the redeemers wallet?

No. A validator script will only validate what's included in a transaction.

But you can include your NFT in the transaction without "lock"ing it. You will want to spend it in the redeeming transaction and return it to the redeemers wallet.

For the transaction to succeed, the validator will check the UTxOs included in the ScriptContext and if the NFT is included among the values, it will say "yes". The off-chain code could be designed in whatever way that includes the NFT in the transaction, but it sounds like you want to ensure it is returned to the transaction builder's wallet (I'm pretty sure that will be the default behavior if you don't specify a recipient of any UTxOs, but of course check that with tests, etc).

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.