<p>This all can be done in a single transaction using <a href="https://github.com/spacebudz/lucid" rel="nofollow noreferrer">lucid</a>. Suggest you to see examples <a href="https://github.com/spacebudz/lucid/tree/main/src/examples" rel="nofollow noreferrer">here</a>. You can use <code>payToContract</code> to pay Ada / native token and simultaneously, <code>mintAssets</code> to mint them (in your minting script, check script context to see whether the required amount is getting transferred to required address). Can see a similar example I coded for my project <a href="https://github.com/adaplays/adaplays.xyz/blob/main/pages/games/rps/new-game.tsx#L89" rel="nofollow noreferrer">here</a>.</p>

CC BY-SA 4.0
2022-11-17T06:46:36.013Z
2022-11-17T06:46:36.013Z
Sourabh
<p>I have integrated a Cardano wallet into my site and done some basic interactions.
I am hoping to get a sample, example and/or guidance on how to build the transaction I am interested in implementing:</p>
<p>Scenario:</p>
<ul>
<li>User visits my site, connects their wallet.</li>
<li>User pays an amount of ADA or an amount of a native token to mint an NFT.</li>
<li>User has NFT in their wallet now, and site can verify it is there as a means of confirming paid membership.</li>
</ul>
<p>So the transaction I need to build:</p>
<p>User pays an amount of ADA or a native token to mint an NFT.
=&gt; ADA gets transferred from the users wallet to the wallet of the site, NFT gets minted and sent to users wallet.</p>
<p>Has anyone here done this?</p>

<wallet><nft><minting>
How to build the transaction needed to have a user pay to mint an NFT
# How to build the transaction needed to have a user pay to mint an NFT

(Asked by: username_0 on 2022-11-16)

I have integrated a Cardano wallet into my site and done some basic interactions.
I am hoping to get a sample, example and/or guidance on how to build the transaction I am interested in implementing:

Scenario:

* User visits my site, connects their wallet.
* User pays an amount of ADA or an amount of a native token to mint an NFT.
* User has NFT in their wallet now, and site can verify it is there as a means of confirming paid membership.

So the transaction I need to build:

User pays an amount of ADA or a native token to mint an NFT.
=> ADA gets transferred from the users wallet to the wallet of the site, NFT gets minted and sent to users wallet.

Has anyone here done this?

**Tags:** wallet, nft, minting

---

## 1 answers

### Answer by username_1 on 2022-11-17. Score: 1

This all can be done in a single transaction using [lucid](https://github.com/spacebudz/lucid). Suggest you to see examples [here](https://github.com/spacebudz/lucid/tree/main/src/examples). You can use `payToContract` to pay Ada / native token and simultaneously, `mintAssets` to mint them (in your minting script, check script context to see whether the required amount is getting transferred to required address). Can see a similar example I coded for my project [here](https://github.com/adaplays/adaplays.xyz/blob/main/pages/games/rps/new-game.tsx#L89).


---

