Socket
Book a DemoInstallSign in
Socket

chainpoint-connector

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chainpoint-connector

Reference implementation of a Chainpoint web service integration

0.0.2
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Chainpoint Connector

Chainpoint Connector is an easy way to manage retrieval of proofs from the Chainpoint Network. Because proof submission and retrieval from the blockchain are highly asynchronous processes, Connector is designed to queue up and execute callbacks when proofs become available.

Installation

npm install chainpoint-connector --save-prod

or, if you want the latest fixes,

npm install https://github.com/chainpoint/chainpoint-connector --save-prod

This library is an ECMAscript module and must be used with import-from syntax.

Usage

Connector uses redis as a persistent datastore. After connecting with redis and setting up the task scheduler, you can define a custom callback method to accept and store the proof results when they arrive. The callback is passed the following parameters:

  • any upstream error
  • time (ms)
  • an optional id that can be added to allow your system to identify a proof when retrieved
  • the type of proof (cal or btc, standing for calendar or bitcoin anchor)
  • the proof returned by the Chainpoint Network

Example:

import ChainpointConnector from 'chainpoint-connector'


async function submitAndMonitor() {
    const chpconn = new ChainpointConnector("redis", 6379)
    await chpconn.connect()
    chpconn.setCallback(async function (error, time, id, type, proofs) {
        if (!error && type == "btc") {
            console.log(proofs)
            //update your database with results
        }
    })
    let hashes = [
        '1d2a9e92b561440e8d27a21eed114f7018105db00262af7d7087f7dea9986b0a',
        '2d2a9e92b561440e8d27a21eed114f7018105db00262af7d7087f7dea9986b0a',
        '3d2a9e92b561440e8d27a21eed114f7018105db00262af7d7087f7dea9986b0a'
    ]
    await chpconn.submitHashes('custom ID', hashes)
}

submitAndMonitor()

Keywords

chainpoint

FAQs

Package last updated on 02 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.