Skip to main content
Version: next

Module: deploy

Functions

compileVerifier

compileVerifier(contractName, vkey): Promise<{ abi: any ; bytecode: any }>

Compile the verifier smart contract with solc

Parameters

NameTypeDescription
contractNamestringThe name of output verifier contract
vkeyanyThe verification key of the verifier

Returns

Promise<{ abi: any ; bytecode: any }>

Output the compiled abi and bytecode

Defined in

packages/contracts/deploy/utils.ts:130


createVerifierName

createVerifierName(circuitName): string

Create name of the verifier contracts. Capitalize the first character and add Verifier at the end.

Parameters

NameTypeDescription
circuitNamestringName of the circuit, which can be chosen from Circuit

Returns

string

Defined in

packages/contracts/deploy/utils.ts:54


deployUnirep

deployUnirep(deployer, settings?, prover?): Promise<Unirep>

Deploy the unirep contract and verifier contracts with given deployer and settings

Parameters

NameTypeDescription
deployerSignerA signer who will deploy the contracts
settings?CircuitConfigThe settings that the deployer can define. See CircuitConfig
prover?ProverThe prover which provides vkey of the circuit

Returns

Promise<Unirep>

The Unirep smart contract

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.

Defined in

packages/contracts/deploy/deploy.ts:189


deployVerifier

deployVerifier(deployer, circuitName, prover?): Promise<Contract>

Parameters

NameTypeDescription
deployerSignerA signer or an ethereum wallet
circuitNamestringName of the circuit, which can be chosen from Circuit
prover?ProverThe prover which provides vkey of the circuit

Returns

Promise<Contract>

The deployed verifier smart contract

Defined in

packages/contracts/deploy/deploy.ts:66


deployVerifierHelper

deployVerifierHelper(unirepAddress, deployer, circuitName, prover?): Promise<Contract>

Parameters

NameTypeDescription
unirepAddressstring-
deployerSignerA signer or an ethereum wallet
circuitNameCircuitName of the circuit, which can be chosen from Circuit
prover?ProverThe prover which provides vkey of the circuit

Returns

Promise<Contract>

The deployed verifier helper contracts

Defined in

packages/contracts/deploy/deploy.ts:137


deployVerifierHelpers

deployVerifierHelpers(unirepAddress, deployer, prover?): Promise<{ [circuit: string]: ethers.Contract; }>

Parameters

NameTypeDescription
unirepAddressstring-
deployerSignerA signer or an ethereum wallet
prover?ProverThe prover which provides vkey of the circuit

Returns

Promise<{ [circuit: string]: ethers.Contract; }>

All deployed verifier helper contracts

Defined in

packages/contracts/deploy/deploy.ts:112


deployVerifiers

deployVerifiers(deployer, prover?): Promise<{ [circuit: string]: string; }>

Parameters

NameTypeDescription
deployerSignerA signer or an ethereum wallet
prover?ProverThe prover which provides vkey of the circuit

Returns

Promise<{ [circuit: string]: string; }>

All deployed verifier smart contracts

Defined in

packages/contracts/deploy/deploy.ts:95


genVerifier

genVerifier(contractName, vk): string

Generate verifier smart contract with a given verification key.

Parameters

NameTypeDescription
contractNamestringThe name of the verifier contract
vkanyThe verification key which is generated by snark protocol

Returns

string

The string of the verifier content

Defined in

packages/contracts/deploy/utils.ts:66


linkLibrary

linkLibrary(bytecode, libraries?): string

Link the library bytecode to a compiled smart contract bytecode.

Parameters

NameTypeDescription
bytecodestringThe compiled smart contract bytecode
librariesObjectThe name and the address of the library

Returns

string

The combined bytecode

Example

linkLibrary(
incArtifacts.bytecode,
{
['poseidon-solidity/PoseidonT3.sol:PoseidonT3']: PoseidonT3.address,
}
)

Defined in

packages/contracts/deploy/utils.ts:22


retryAsNeeded

retryAsNeeded(fn, maxRetry?): Promise<any>

Try a function several times.

Parameters

NameTypeDefault valueDescription
fnanyundefinedThe function will be executed.
maxRetrynumber10The maximum number of trying functions.

Returns

Promise<any>

Defined in

packages/contracts/deploy/deploy.ts:45


tryPath

tryPath(file): any

Try to find an artifact file in the paths.

Parameters

NameTypeDescription
filestringThe name of the file that will be searched.

Returns

any

The found artifacts

Defined in

packages/contracts/deploy/utils.ts:159