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 🙏

© 2024 – Pkg Stats / Ryan Hefner

zk-trace-sdk

v1.0.3

Published

Sdk for integrating ZK trace into supplychain managment systems

Downloads

5

Readme

zkTrace (Blockchain native supply chain managment protocol)

zkTrace is a protocol that combines the power of blockchain for trustlessness, and zero knowledge for privacy, to provide safe and confidential business processes, correctly order events and increase work flow at no cost (gasless).

The protocol provides the Trace Agreement smart contract that handles the entire lifecycle of the supply chain. The Trace Agreement contract becomes active after an agreement has been met between supplier and buyer. A cryptographic zero knowledge proof is generated for the trace agreement. This is to validate the private collaborations between parties without leaking sensitive data.

It is built to ensure easy and trustless agreement between corporations and entities.

zkTrace allows you to customize and describe business processes, regardless of how complex they are, using smart contracts.

All Trace agreement business logic and data are encrypted and stored on IPFS using IPLD (Inter-Planetary-Linked-Data). This ensures the Trace agreement data can always be traced and verified.

Verifying Trace agreement

The verifier addresses are not stored on the smart contract. They are encrypted and added to the trace data stored on IPFS on intilization of trace agreemenmt. zkTrace uses MerkelTree and unique nullifiers to ensure privacy and coustomization of the different stages of the supply chain. Hence there are no limit to the amount of verifiers a Trace agreement contract can have.

Interracting with the protocol

zkTrace protocol provides a javascript SDK the can be used to interract with the protocol. This SDK provides all the methods to needed integrate or build with zkTrace

Using zk-trace-sdk @v1.0.0

First import zk-trace-sdk

npm i zk-trace-sdk
import ZkTrace from "zk-trace-sdk";
import { ethers, Wallet } from "ethers";
import dotenv from "dotenv";
dotenv.config();

const traceClient = new ZkTrace({
  nodeEndpoint: process.env.NODE_RPC_URL,
  factoryAddress: "0x3907977976DBB9eAd7e825b3d34B5d0F97D22bC5",
  traceHubAddress: "0x839201D2756E8fe9ee9a32170EC295E40F5fb22d",
  web3storageApiKey: process.env.WEB3_STORAGE_KEY,
});

@params privacy can either be (1 for public) or (2 for private)

const creatTraceAgreement = async (traceAdmin, supplier, privacy) = {

    const provider = new ethers.providers.JsonRpcProvider(process.env.NODE_RPC_URL);

    /**
     const provider = await traceClient.getProvider()
     */

    const wallet = new Wallet(process.env.PRIVATE_KEY);
    const signer = wallet.connect(provider);

    const result = await traceClient.createTraceAgreement(
      traceAdmin,
      supplier,
      privacy,
      signer
    );

    console.log(result);

    /**
        {
            message: "ok",
            transactionHash: "0x1669b851a52e88d8e8ba5de03c24216e0f33b7e4f0dc35ccee65edfea81fd074",
            details: {
                agreementAddress: "0x09bE60B98b1766bFD5318bc649fdC5de3498F847",
                agreementId: "10"
            }
        }
    */
}

web3.storage is used as a pinning service for easy pinning of The IPLD data blocks or CAR file. web3StorageApiKey is used to create a storage instance in the SDK. This can be gotten from https://web3.storage/ -Create an account -Request an apiKey.

View encrypted IPLD data

import ZkTrace from "zk-trace-sdk";
import { ethers, Wallet } from "ethers";
import dotenv from "dotenv";
dotenv.config();

const traceClient = new ZkTrace({
  nodeEndpoint: process.env.NODE_RPC_URL,
  factoryAddress: "0x3907977976DBB9eAd7e825b3d34B5d0F97D22bC5",
  traceHubAddress: "0x839201D2756E8fe9ee9a32170EC295E40F5fb22d",
  web3storageApiKey: process.env.WEB3_STORAGE_KEY,
});

const readData = async (cid, key) => {
    const result = await traceClient.decryptData(cid, key);
    console.log(result);

    /**
        {
            previousBlockId: "",
            verifiers: [
                <VERIFIER 1 ADDRESS>,
                <VERIFIER 2 ADDRESS>,
                <VERIFIER 3 ADDRESS>,
                <VERIFIER 4 ADDRESS>
                ],
            txDetails: {
                supplier: <SUPPLIER ADDRESS>,
                pickupDate: <DATE IN UINX TIMESTAMP>,
                totalPrice: <PRICE>,
                location: <PICKUP VERIFIED PICKUP LOCATION>,
                items: [
                    {name: "Under armour", quantity: 10000,},
                    {name: "Nike", quantity: 2000}
                ],
            }
        }
     */

     //@notice data returned is equal to data encrypted.
     //@dev The txDetails object is fully customizable to your need / data modual you wish to follow.
}

Deployed addresses

Famtom Testnet

| Smart contract | Address | | -------------------------- | ------------------------------------------ | | traceFactoryAddress | 0x3907977976DBB9eAd7e825b3d34B5d0F97D22bC5 | | traceHubAddress | 0x839201D2756E8fe9ee9a32170EC295E40F5fb22d | | traceImplimentationAddress | 0x8E895b6A4440b797D7b2d018a3f105F59fB26D3d |

@v1.0.0: -Initial implementation.

@v1.0.1: -Added method to view IPLD encrypted data. -EIP1559 support