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.

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.

function getDealByOwner(
    address owner
) 
public 
view 
returns (
    DealStruct[] memory
)
  • getDealByCounterpart: This function returns all the deals where a given address is the counterpart.

function getDealByCounterpart(
    address counterpart
) 
public 
view 
returns (
    DealStruct[] memory
);
  • getSendRequestByDeal: This function returns all the SendRequests associated with a given deal.

function getSendRequestByDeal(
    uint256 tokenId
) 
public 
view 
returns (
    SendRequest[] memory
);
  • addSendRequest: This function allows associating a SendRequest to a deal using its idHash.

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.

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

Last updated