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 theNFTSale
.payment
: ACoin<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:
Verify
sale.is_active
is true.Check that the buyer is not on the deny list.
Validate the payment covers
price_per_nft * number_of_NFTs
.Deduct the NFTs from the sale, transfer them to the buyer, and deposit the payment into the sale’s currency balance.
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.
Last updated