# Purchasing NFTs from a Sale

**`purchase_nfts<CURRENCY>(...)`**\
**Purpose**: Allows a buyer to purchase one or multiple NFTs directly from the sale by paying the required currency.

**Key Parameters**:

* `sale`: A mutable reference to the `NFTSale`.
* `payment`: A `Coin<CURRENCY>` containing enough value to cover the purchase.
* `asset_ids`: A vector of the specific NFTs (by asset\_id) the buyer wishes to purchase.
* `collection_cap`: For checking deny list and other constraints.
* `ctx`: The transaction context.

**Process**:

1. Verify `sale.is_active` is true.
2. Check that the buyer is not on the deny list.
3. Validate the payment covers `price_per_nft * number_of_NFTs`.
4. Deduct the NFTs from the sale, transfer them to the buyer, and deposit the payment into the sale’s currency balance.
5. Emit an `NFTPurchased` event and update user balances.

**Use Cases**:

* A collector buys 3 NFTs from a sale, paying the set price in the required currency.
* Automated scripts purchase NFTs in batches if they match investment criteria.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.artinals.com/artinals-protocol/functions-and-entry-points/purchasing-nfts-from-a-sale.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
