Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bch-dex-lib

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bch-dex-lib

An npm JavaScript library for browser and node.js that incorporates the SWaP protocol used by bch-dex.

  • 1.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

bch-dex-lib

This is a library for use in both browser and node.js JavaScript applications. It incorporates the basic SWaP protocol used by bch-dex.

The purpose of this library is build a web and Android app that can let Takers purchase tokens using the bch-dex protocol. Makers still still need to run the bch-dex back end to make Offers and accept Counter-Offers. But an app using this library allows Takers to issue a Counter Offer without needing to run back end software.

This library depends on minimal-slp-wallet and p2wdb. Both of these libraries must be instantiated and passed in as arguments when instantiating this library.

Installation

npm install --save-exact bch-dex-lib

Usage

async function start() {
  try {
    // Global npm libraries
    const BchWallet = require('minimal-slp-wallet/index')
    const { Read, Write } = require('p2wdb/index')

    // Customize the two variables below for your own test. The mnemonic
    // should control about $0.20 USD of BCH. The p2wdbHash should be for a
    // valid Offer in the market.
    const mnemonic = 'gaze result fortune pulse jeans lucky tape build maximum puppy urban size'
    const p2wdbHash = 'zdpuAvWMYm7bfHTxbNwsWYmrkK3cnhtH2MzQ7QS74uYbkM3ja'

    // Instantiate dependencies
    const wallet = new BchWallet(mnemonic, { interface: 'consumer-api' })
    await wallet.walletInfoPromise
    const p2wdbRead = new Read()
    const p2wdbWrite = new Write({ wif: wallet.walletInfo.privateKey, interface: 'consumer-api' })

    // Instantiate the Take library.
    const take = new Take({ wallet, p2wdbRead, p2wdbWrite })

    // Generate a Counter Offer to take the other side of the trade expressed in the Offer.
    const hash = await this.p2wdbWrite.postEntry(counterOfferData, offerData.appId)

    console.log(`Counter Offer generated with P2WDB entry ${hash}`)
  } catch(err) {
    console.error(err)
  }
}
start()

Donate

This open source software is developed and maintained by the Permissionless Software Foundation. If this library provides value to you, please consider making a donation to support the PSF developers:

bitcoincash:qqsrke9lh257tqen99dkyy2emh4uty0vky9y0z0lsr

Licence

MIT

Keywords

FAQs

Package last updated on 08 Oct 2022

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc