@unirep/core

Client library for protocol 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/core package with npm:

npm i @unirep/core

or yarn:

yarn add @unirep/core

๐Ÿ“” Usage

Synchronizer โฒ

Construct a synchronizer

import { Synchronizer, schema } from '@unirep/core'
import { getUnirepContract, Unirep } from '@unirep/contracts'
import { DB, SQLiteConnector } from 'anondb/node'

// connect a unirep contract with the address and a provider
const unirepContract: Unirep = getUnirepContract(address, provider)
// initialize a database
const db: DB = await SQLiteConnector.create(schema, ':memory:')

// 1. initialize a synchronizer
const synchronizer = new Synchronizer(db, provider, unirepContract)
// 2. start listening to unriep contract events
await synchronizer.start()
// 3. wait until the latest block is processed
await synchronizer.waitForSync()

Example: use the synchronizer to generate unirep state

UserState ๐Ÿ‘ค

Construct a user state

Example: use the user state to generate proofs

Utils ๐Ÿงณ

Example: Compute an epoch key

Last updated

Was this helpful?