<p>I'd check out using <a href="https://alpha.marlowe.iohkdev.io/doc/haddock/plutus-ledger/html/Ledger-Constraints.html#v:MustSpendPubKeyOutput" rel="nofollow noreferrer"><code>mustSpendPubKeyOutput</code></a> in your off-chain transaction constraints.</p>
<p>To answer your question directly:</p>
<blockquote>
<p>Can a smart contract read the presence of an NFT in the redeemers wallet?</p>
</blockquote>
<p>No. A validator script will only validate what's included in a transaction.</p>
<p>But you can include your NFT in the transaction without &quot;lock&quot;ing it. You will want to spend it in the redeeming transaction and return it to the redeemers wallet.</p>
<p>For the transaction to succeed, the validator will  check the UTxOs included in the <code>ScriptContext</code> and if the NFT is included among the values, it will say &quot;yes&quot;. 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).</p>

CC BY-SA 4.0
2021-09-20T21:53:11.070Z
2021-09-20T21:53:11.070Z
Mitchell Turner
<p>I want to use an NFT as a form of authentication for a Plutus contract.</p>
<p>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 &quot;lock&quot; the NFT such that the user can only submit a single transaction.</p>
<p>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.</p>
<p><a href="https://i.sstatic.net/tRHvk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/tRHvk.png" alt="enter image description here" /></a></p>
<p>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?</p>
<ul>
<li>Note I am new to a lot of this so feel free to tell me I have got this wrong.</li>
</ul>

<plutus><smart-contract><nft>
Can a smart contract read the presence of an NFT in the redeemers wallet?
# Can a smart contract read the presence of an NFT in the redeemers wallet?

(Asked by: username_0 on 2021-09-20)

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](https://i.sstatic.net/tRHvk.png)](https://i.sstatic.net/tRHvk.png)

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.

**Tags:** plutus, smart-contract, nft

---

## 1 answers

### Answer by username_1 on 2021-09-20. Score: 3 | Accepted answer

I'd check out using [`mustSpendPubKeyOutput`](https://alpha.marlowe.iohkdev.io/doc/haddock/plutus-ledger/html/Ledger-Constraints.html#v: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).


---

