# Deal

## ConfidentialDeal Contract

The `ConfidentialDeal` contract is a significant component of the NotVault SDK. It primarily extends the ERC721 functionality to implement confidential deals that interact with a Confidential Vault and supports the verification of zkSNARKs proofs to maintain privacy. This contract leverages OpenZeppelin contracts for various functionalities such as ERC721, pausable, ownable, and burnable features.

### Structure Definitions

* **DealMeta**: This structure contains the metadata of a deal, including owner, counterpart, denomination, name, description, notional, and initial.

### Public Functions

* **pause** and **unpause**: These functions allow the owner of the contract to pause and unpause the contract respectively.
* **tokenURI**: This function returns the URI of the token based on the token ID.
* **safeMint**: This function allows the owner to mint a token safely. The token metadata (URI) and other deal-specific data (counterpart, minimum commitment, and idHash) are associated with the token during minting. The nonce for the owner and the counterpart is incremented, and the token is added to the owner and counterpart's pool.

```solidity
function safeMint(
    address counterpart,
    uint256 minCommitment,
    uint256 idHash,
    string memory uri
) 
public 
returns (uint256);
```

* **getDealByOwner**: This function returns all the deals initiated by a given owner.

```solidity
function getDealByOwner(
    address owner
) 
public 
view 
returns (
    DealStruct[] memory
)
```

* **getDealByCounterpart**: This function returns all the deals where a given address is the counterpart.

```solidity
function getDealByCounterpart(
    address counterpart
) 
public 
view 
returns (
    DealStruct[] memory
);
```

* **getSendRequestByDeal**: This function returns all the SendRequests associated with a given deal.

```solidity
function getSendRequestByDeal(
    uint256 tokenId
) 
public 
view 
returns (
    SendRequest[] memory
);
```

* **addSendRequest**: This function allows associating a SendRequest to a deal using its `idHash`.

```solidity
function addSendRequest(
    uint256 tokenId,
    uint256 idHash
)
public;
```

* **accept**: This function allows the counterpart of a deal to accept it. The function verifies the zkSNARKs proof, checks the minimum commitment, and compares the idHash before marking the deal as accepted.

```solidity
function accept(
    uint256 tokenId,
    bytes calldata proof,
    uint[3] memory input
)
public;
```


---

# 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.notcentralised.com/contracts/deal.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.
