Skip to main content
Version: 2.1.x

Deployment

Import the deployment functions with:

import { deployUnirep } from '@unirep/contracts/deploy'

deployUnirep​

Deploy Unirep.sol and its verifiers and connect libraries.

const deployUnirep = async (
deployer: ethers.Signer,
_settings: CircuitConfig = CircuitConfig.default,
prover?: Prover
): Promise<Unirep>

For example:

import { ethers } from 'ethers'
import { Unirep } from '@unirep/contracts'
import { deployUnirep } from '@unirep/contracts/deploy'
const privateKey = 'YOUR/PRIVATE/KEY'
const provider = 'YOUR/ETH/PROVIDER'
const deployer = new ethers.Wallet(privateKey, provider);
const unirepContract: Unirep = await deployUnirep(deployer)
caution

The default circuit configuration is set in CircuitConfig.ts.
Please make sure the CircuitConfig matches your prover.

If you don't compile circuits on your own, please don't change the _settings and prover.
See the current prover and settings of deployed contracts: 🤝 Testnet Deployment.

deployVerifier​

Deploy a given circuit verifier. The verifier is with a certain interface: IVerifier.sol.

const deployVerifier = async (
deployer: ethers.Signer,
circuit: Circuit | string,
prover?: Prover
): Promise<ethers.Contract>

deployVerifiers​

Deploy all known circuit verifiers.

const deployVerifiers = async (
deployer: ethers.Signer,
prover?: Prover
): Promise<{ [circuit: string]: Promise<string> }>

deployVerifierHelpers​

Deploy all known circuit verifier helpers. A helper can help with decoding public signals. For example: EpochKeyVerifierHelper.sol

const deployVerifierHelpers = async (
unirepAddress: string,
deployer: ethers.Signer,
prover?: Prover
)

deployVerifierHelper​

Deploy a given circuit verifier helper. For example: EpochKeyVerifierHelper.sol

const deployVerifierHelper = async (
unirepAddress: string,
deployer: ethers.Signer,
circuit: Circuit,
prover?: Prover
): Promise<ethers.Contract>