npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

bonsai-sdk

v1.0.3

Published

Bonsai lets users generate proofs for their zkVM applications, without using their own hardware for proof generation. Users specify which zkVM application they want to run, as well as the inputs to that program, and Bonsai returns a proof.

Readme

Bonsai-sdk

Bonsai lets users generate proofs for their zkVM applications, without using their own hardware for proof generation. Users specify which zkVM application they want to run, as well as the inputs to that program, and Bonsai returns a proof.

With the Bonsai SDK as npm package you can now use the power of zkVM in your browser.

Installation

To install the Bonsai SDK in your frontend, you just need to run in your projects directory the command:

npm i bonsai-sdk

Setting up

Before you start, you have first set up your env variables. Bonsai needs to env variables:

[FRAMEWORK_PREFIX]BONSAI_API_KEY=<YOUR API KEY>
[FRAMEWORK_PREFIX]BONSAI_API_URL=<BONSAI API URL>

This npm package is made to adapt for all Javascript/Typescript frameworks prefix, for example the Next framework have the prefix NEXT_PUBLIC_ so the env variables in Next should be set like:

NEXT_PUBLIC_BONSAI_API_KEY=<YOUR API KEY>
NEXT_PUBLIC_BONSAI_API_URL=<BONSAI API URL>

Example

Bellow will be presented a example of use of the Bonsai SDK sending inputs to a zkVM application and receiving back the proof:

import { ethers } from "ethers";
// metadata.json is a file where i chose to store the image id that i 
// want to interact with and the bonsai version
import metadata from './metadata.json'  assert { type: 'json' };
import {getSealAndJournal, Client} from 'bonsai-sdk'

async function genProof(n) {
    const types = ["uint256"];
    const values = [n];

    const encoded = ethers.AbiCoder.defaultAbiCoder().encode(types, values);

    const bonsaiClient = await Client.fromEnv(metadata.version)
    let inputId = await bonsaiClient.uploadInput(encoded)
    
    let session = await bonsaiClient.createSession(metadata.image_id, inputId, [], false)
    let receipt = undefined
    while (true) {
        // Get current status (assumed to return a Promise)
        const res = await session.status(bonsaiClient);

        if (res.status === "RUNNING") {
            console.error(
                `Current status: ${res.status} - state: ${res.state || ""} - continue polling...`
            );
            // Wait for 15 seconds before polling again
            await new Promise(resolve => setTimeout(resolve, 15000));
            continue;
        }

        if (res.status === "SUCCEEDED") {
            if (!res.receipt_url) {
                throw new Error("API error, missing receipt on completed session");
            }
            const receiptUrl = res.receipt_url;
            const receiptBuf = await bonsaiClient.download(receiptUrl);
            // getSealAndJournal is an extra function that receives the proof bincode and 
            // returns the seal and journal to simplify the verification process
            let proof = await getSealAndJournal(receiptBuf)
            // printing Seal and Journal just to check the result
            console.log("seal ", proof[0])
            console.log("journal ", proof[1])
            
        } else {
            throw new Error(
                `Workflow exited: ${res.status} - | err: ${res.error_msg || ""}`
            );
        }

        // Exit the loop once done
        break;
    }
}