GithubHelp home page GithubHelp logo

opacitylabs / client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from witnessco/client

0.0 0.0 0.0 107 KB

Typescript SDK for Witness

Home Page: https://www.npmjs.com/package/@witnessco/client

License: MIT License

TypeScript 100.00%

client's Introduction

Witness Client

Features

Witness Client: A client for interacting with Witness.

  • Fetch-based client built on OpenAPI specification
  • Supports customizing fetch function for different environments
  • Configurable with API key and custom RPC URL
  • Verifies proofs against the chain

Usage

bun add @witnessco/client
import { WitnessClient } from '@witnessco/client'

// Instantiate a new client, default params should suffice for now.
const witness = new WitnessClient()

// Unique string, so we get an unseen leafHash.
const sampleString = `Check the chain! @ ${Date.now()}`
const leafHash = witness.hash(sampleString)

console.log(`Posting leaf hash ${leafHash}`)
await witness.postLeaf(leafHash)
console.log('Waiting for onchain inclusion (may take up to 10min)')
await witness.waitForCheckpointedLeafHash(leafHash)

// Get the timestamp for the leaf.
const timestamp = await witness.getTimestampForLeafHash(leafHash)
console.log(`Leaf ${leafHash} was timestamped at ${timestamp}`)

// Get and verify proof.
const proof = await witness.getProofForLeafHash(leafHash)
const verified = await witness.verifyProofChain(proof)
console.log(`Proof verified: ${verified}`)

See this repl for a live example.

Contract Deployments

Canonical deployments for Witness.sol are available as follows:

Chain ID Deployment Address
Mainnet (1) 0x0000000e143f453f45B2E1cCaDc0f3CE21c2F06a
Base (8453) 0x0000000e143f453f45B2E1cCaDc0f3CE21c2F06a
Optimism (10) 0x0000000e143f453f45B2E1cCaDc0f3CE21c2F06a
Sepolia (11155111) 0x00000008bcf12Eeb9E4162687D6D251f0F4e7FC2
Base Sepolia (84532) 0x0000000159C8253802551eEaf8b475db1A50d712
Optimism Sepolia (11155420) 0x0000000a3fa5CFe56b202F376cCa7334c93aEB8b

See the contracts-core repo for more details.

More Info

See docs.witness.co for more background on Witness, or the contracts-core repo for more details on the contracts.

Built With

client's People

Contributors

sinasab avatar github-actions[bot] avatar hmac512 avatar 0xosprey avatar sina-wit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.