@unirep/contracts

Client library for contracts related functions which are used in UniRep protocol.

Github license NPM version Downloads Linter eslint Code style prettier

๐Ÿ›  Install

npm or yarn

Install the @unirep/contracts package with npm:

npm i @unirep/contracts

or 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 build

By 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

๐Ÿ™‹๐Ÿปโ€โ™‚๏ธ Call Unirep contract in DApps

  • ๐Ÿšธ Please copy verifiers/*.sol files to node_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?