Skip to content

Write your smart contract with Receptor

Receptor compatible smart contracts use the ZKPVerifiier contract, which implements on chain zero-knowledge proof verification.

All the functions for ZK verification are in the ZKPVerifier Contract and should be used by your Receptor Smart Contract to perform the proof verification.

The ZKPVerifier Contract has two hooks: _beforeProofSubmit and _afterProofSubmit. These hooks refer to functions or events that are triggered just before and after the submission of a zero-knowledge proof (ZKP) in the ZKPVerifier contract. They provide the flexibility to customise the behaviour of the contract to suit specific requirements.

_beforeProofSubmit: This hook is called just before the submission of the ZKP proof. It allows you to perform any custom logic, checks, or modifications to the contract state before the proof is submitted. This can be useful for tasks such as validating additional conditions, updating variables, or verifying the authenticity of supporting data.

_afterProofSubmit: This hook is triggered right after the submission of the ZKP proof. It allows you to perform any actions, updates, or events in response to the successful submission of the proof. This could include updating records, emitting events, or triggering further processes based on the outcome of the proof submission.

Here, you can find an example of Receptor Smart Contract.

Deploying your Receptor Smart Contract

After updating _beforeProofSubmit and _afterProofSubmit deploy your Receptor Smart Contract using the following command task deployBSC in the verifier-backend

Read More:

Initialise Receptor Smart Contract

Initialise Receptor Smart Contract by specifying it's token address and ABI.

const rpcUrl = process.env.RPC_URL as string;
let walletKey = process.env.WALLET_KEY as string;
walletKey = walletKey.includes("\n") ? walletKey.split("\n")[0] : walletKey;

const provider = new ethers.JsonRpcProvider(rpcUrl);
const wallet = new ethers.Wallet(walletKey, provider);
const BSC = new ethers.Contract(BusinessSmartContract.token, BSC20.abi, wallet);

Next Up: Create credential request →