Module: deploy
Functions
compileVerifier
▸ compileVerifier(contractName
, vkey
): Promise
<{ abi
: any
; bytecode
: any
}>
Compile the verifier smart contract with solc
Parameters
Name | Type | Description |
---|---|---|
contractName | string | The name of output verifier contract |
vkey | any | The 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
Name | Type | Description |
---|---|---|
circuitName | string | Name 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
Name | Type | Description |
---|---|---|
deployer | Signer | A signer who will deploy the contracts |
settings? | CircuitConfig | The settings that the deployer can define. See CircuitConfig |
prover? | Prover | The 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)
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
Name | Type | Description |
---|---|---|
deployer | Signer | A signer or an ethereum wallet |
circuitName | string | Name of the circuit, which can be chosen from Circuit |
prover? | Prover | The 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
Name | Type | Description |
---|---|---|
unirepAddress | string | - |
deployer | Signer | A signer or an ethereum wallet |
circuitName | Circuit | Name of the circuit, which can be chosen from Circuit |
prover? | Prover | The 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
Name | Type | Description |
---|---|---|
unirepAddress | string | - |
deployer | Signer | A signer or an ethereum wallet |
prover? | Prover | The 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
Name | Type | Description |
---|---|---|
deployer | Signer | A signer or an ethereum wallet |
prover? | Prover | The 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
Name | Type | Description |
---|---|---|
contractName | string | The name of the verifier contract |
vk | any | The 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
Name | Type | Description |
---|---|---|
bytecode | string | The compiled smart contract bytecode |
libraries | Object | The 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
Name | Type | Default value | Description |
---|---|---|---|
fn | any | undefined | The function will be executed. |
maxRetry | number | 10 | The 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
Name | Type | Description |
---|---|---|
file | string | The name of the file that will be searched. |
Returns
any
The found artifacts