@unirep/contracts
Version:
Client library for contracts related functions which are used in UniRep protocol.
65 lines (64 loc) • 3.27 kB
TypeScript
import { ethers } from 'ethers';
import { Circuit, Prover, CircuitConfig } from '@unirep/circuits';
import { Unirep } from '../typechain';
/**
* Try a function several times.
* @param fn The function will be executed.
* @param maxRetry The maximum number of trying functions.
*/
export declare const retryAsNeeded: (fn: any, maxRetry?: number) => Promise<any>;
/**
* @param deployer A signer or an ethereum wallet
* @param circuitName Name of the circuit, which can be chosen from `Circuit`
* @param prover The prover which provides `vkey` of the circuit
* @returns The deployed verifier smart contract
*/
export declare const deployVerifier: (deployer: ethers.Signer, circuitName: Circuit | string, prover?: Prover) => Promise<ethers.Contract>;
/**
* @param deployer A signer or an ethereum wallet
* @param prover The prover which provides `vkey` of the circuit
* @returns All deployed verifier smart contracts
*/
export declare const deployVerifiers: (deployer: ethers.Signer, prover?: Prover) => Promise<{
[circuit: string]: string;
}>;
/**
* @param deployer A signer or an ethereum wallet
* @param prover The prover which provides `vkey` of the circuit
* @returns All deployed verifier helper contracts
*/
export declare const deployVerifierHelpers: (unirepAddress: string, deployer: ethers.Signer, prover?: Prover) => Promise<{
[circuit: string]: ethers.Contract;
}>;
/**
* @param deployer A signer or an ethereum wallet
* @param circuitName Name of the circuit, which can be chosen from `Circuit`
* @param prover The prover which provides `vkey` of the circuit
* @returns The deployed verifier helper contracts
*/
export declare const deployVerifierHelper: (unirepAddress: string, deployer: ethers.Signer, circuitName: Circuit, prover?: Prover) => Promise<ethers.Contract>;
/**
* Deploy the unirep contract and verifier contracts with given `deployer` and settings
* @param deployer A signer who will deploy the contracts
* @param settings The settings that the deployer can define. See [`CircuitConfig`](https://developer.unirep.io/docs/circuits-api/circuit-config)
* @param prover The prover which provides `vkey` of the circuit
* @returns The Unirep smart contract
* @example
* ```ts
* 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`](https://github.com/Unirep/Unirep/blob/1a3c9c944925ec125a7d7d8bfa9990466389477b/packages/circuits/src/CircuitConfig.ts).<br/>
* Please make sure the `CircuitConfig` matches your [`prover`](circuits-api/interfaces/src.Prover.md).
* If you don't compile circuits on your own, please don't change the `_settings` and `prover`.<br/>
* See the current prover and settings of deployed contracts: [🤝 Testnet Deployment](https://developer.unirep.io/docs/testnet-deployment).
* :::
*/
export declare const deployUnirep: (deployer: ethers.Signer, settings?: CircuitConfig, prover?: Prover) => Promise<Unirep>;