0.1.0 • Published 2 years ago

@usemist/sdk v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

MIST SDK

A TypeScript SDK for interacting with MIST zero-knowledge proofs and smart contracts.

Installation

Install the SDK as a dependency in your project with either npm or yarn.

npm:

npm install @usemist/sdk

yarn:

yarn add @usemist/sdk

Getting Started

For generating zero-knowledge proofs needed in the MIST smart contracts, it is recommended to use the Prover class and MIST API.

  1. Setup the prover.
import { Prover } from '@usemist/sdk'

const prover = new Prover({
    baseURI: 'MIST API link',
    apiKey: process.env.MIST_API_KEY
})
  1. Prove membership of signer in account.
// Using setup from step 1
async function main() {
    const proofInputs = generateProofInputs() // Fake function for example purposes
    const { proof, publicSignals, error } = await prover.proveAccountMembership(proofInputs)
}
  1. Generate ZKP for transfers and withdrawals in MIST Pool.
// Using setup from step 1
async function main() {
    const proofInputs = generateProofInputs() // Fake function for example purposes
    const { proof, publicSignals, error } = await prover.proveUTXO(proofInputs)
}
  1. Prove an account meets a specified minimum balance of some token.
// Using setup from step 1
async function main() {
    const proofInputs = generateProofInputs() // Fake function for example purposes
    const { proof, publicSignals, error } = await prover.proveBalance(proofInputs)
}

Development

To develop on the SDK on your own computer, clone the repo and install the dependencies:

yarn

Since it is written in TypeScript, code must be compiled with the command:

yarn build