@usemist/sdk
v0.1.0
Published
A TypeScript SDK for interacting with MIST zero-knowledge proofs and smart contracts
Downloads
4
Readme
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.
- Setup the prover.
import { Prover } from '@usemist/sdk'
const prover = new Prover({
baseURI: 'MIST API link',
apiKey: process.env.MIST_API_KEY
})
- 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)
}
- 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)
}
- 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