# MintDealsNFT

[https://github.com/Paracosm-Labs/mintdeals-contracts/blob/main/contracts/MintDealsNFT.sol](https://github.com/Paracosm-Labs/mintdeals-contracts/blob/main/contracts/MintDealsNFT.sol)

The MintDealsNFT contract is another crucial component of the MintDeals platform, responsible for minting, managing, and redeeming NFTs that represent deals created by club owners. This contract extends the ERC721 standard and includes additional functionality specific to the MintDeals ecosystem.

### Key Functions

#### 1. NFT Minting

**`mintNFT(address recipient, uint256 dealId, string memory metadataURI)`**

* Mints a new NFT representing a deal.
* Only admins (typically the ClubDealRegistry contract) can call this function.
* Assigns a unique token ID, sets the metadata URI, and associates the NFT with a specific deal ID.
* Emits an `NFTMinted` event.

#### 2. Redemption Process

**`requestRedemption(uint256 tokenId)`**

* Allows NFT owners to request redemption of their deal NFT.
* Sets a flag indicating that redemption has been requested.

**`approveRedemption(uint256 tokenId)`**

* Allows admins to approve a redemption request.
* Burns the NFT, effectively redeeming the deal.
* Emits an `NFTRedeemed` event.

**`rejectRedemption(uint256 tokenId)`**

* Allows admins to reject a redemption request.
* Clears the redemption request flag.

#### 3. Metadata Management

**`_setTokenURI(uint256 tokenId, string memory _tokenURI)`**

* Internal function to set the metadata URI for a token.

**`tokenURI(uint256 tokenId)`**

* Public function to retrieve the metadata URI for a token.

### Key Concepts

1. **Deal Representation**: Each NFT represents a specific deal created by a club owner in the MintDeals ecosystem.
2. **Controlled Minting**: Only authorized admins (typically the ClubDealRegistry contract) can mint new NFTs, ensuring that NFTs are created only for valid deals.
3. **Redemption Process**: The contract implements a two-step redemption process:
   * Users request redemption of their NFT.
   * Admins (club owners or platform managers) approve or reject the redemption.
4. **Burning on Redemption**: When a redemption is approved, the NFT is burned, ensuring it can't be used again.
5. **Metadata Storage**: Each NFT has associated metadata (stored off-chain, with the URI stored on-chain) that contains details about the deal.

### Integration with ClubDealRegistry

The MintDealsNFT contract works closely with the ClubDealRegistry contract:

1. When a club member mints a deal in the ClubDealRegistry, it calls the `mintNFT` function of this contract.
2. The `confirmRedemption` function in ClubDealRegistry calls the `approveRedemption` function here.
3. The admin functions in this contract are probably called by ClubDealRegistry or a central admin contract to manage the NFT lifecycle.

By leveraging this contract, MintDeals ensures that each deal is represented as a unique, tradeable NFT, adding an extra layer of value and functionality to the deals offered by clubs on the platform.
