@unirep/contracts
Client library for contracts related functions which are used in UniRep protocol.
๐ Install
npm or yarn
Install the @unirep/contracts package with npm:
npm i @unirep/contractsor yarn:
yarn add @unirep/contracts๐ฉ๐ปโโ๏ธ Haven't deployed a contract yet?
Get circuit keys from one of the following methods
๐ Solution 1. Download circuit keys from server
(TODO) Get circuits files from PSE server
๐ Solution 2. Build circuits locally
git clone https://github.com/Unirep/Unirep.git && \
cd Unirep/ && \
yarn install && \
yarn buildBy default, The zksnarkBuild directory will be found in ./packages/circuits
Compile contracts from the keys
Step 1. Set the zksnarkBuild path in buildVerifier.ts
Step 2. Run compile command
By default, The artifacts directory will be found in ./packages/contracts/build
๐๐ปโโ๏ธ Unirep contract has been compiled
Deploy Unirep contract
Deploy Unirep smart contract with default config:
(TODO) A deploy script
Get unirep contract with address
๐ง๐ปโ๐ป Call Unirep contract with ethers
ethers๐๐ปโโ๏ธ Call Unirep contract in DApps
๐ธ Please copy
verifiers/*.solfiles tonode_modules/@unirep/contracts/verifiers/directories.(TODO) Find a better way to do this.
๐ Other usages
Proofs
An example of epoch key proof 1. Generate an epoch key proof structure
2. Get data from epoch key proof structure
3. Verify the epoch key proof
4. Compute keccak256 hash of the proof
5. The proof structure can help with formatting the proof on chain
Attestation
An example of constructing an Attestation object
Event/ Attestation event
The event enum is used to help with determining the type of the event, which are as the same definition in IUnirep.sol
Last updated
Was this helpful?