Now that we've implemented the smart contract portion of the integration, it's onto tying it with the frontend Dapp that will generate the proofs necessary for passing in to the contract.
1. Install SDK in Dapp
yarn add @thesingularitynetwork/singularity-sdk
yarn add @thesingularitynetwork/darkpool-v1-proof
(Depends on ether.js v6)
2. Initialize the Darkpool
First, initialize darkpool with signer, chainId, relayer config and contract configuration:
4. User generates defiParameters and generates Proof
Next, using our user's deposit(s), we'll generate our defiParameters from the input parameters to the DeFi contract's method: [amountIn, minAmount]. Here, we're setting amountOut to be ethNote.amount * 8n / 10n.
Once we've generated our defiParameters variable, we pass all these details into the SDK library's infraService object that processes and generates the ZK proof: