ddpay
Robust dPay blockchain client library that runs in both node.js and the browser.
note As of version 0.7.0 WebSocket support has been removed. The only transport provided now is HTTP(2). For most users the only change required is to swap wss://
to https://
in the address. If you run your own full node make sure to set the proper CORS headers if you plan to access it from a browser.
Browser compatibility
Installation
Via npm
For node.js or the browser with browserify or webpack.
npm install ddpay
From cdn or self-hosted script
Grab dist/ddpay.js
from a release and include in your html:
Or from the unpkg cdn:
Make sure to set the version you want when including from the cdn, you can also use ddpay@latest
but that is not always desirable. See unpkg.com for more information.
Usage
In the browser
See the demo source for an example on how to setup a livereloading TypeScript pipeline with wintersmith and browserify.
In node.js
With TypeScript:
for await of client.blockchain.getBlocks
With JavaScript:
var ddpay = var client = 'https://api.dpays.io'var key = ddpayPrivateKey clientbroadcast
With ES2016 (node.js 7+):
const Client = const client = 'https://api.dpays.io' { const props = await clientdatabase console client}
With node.js streams:
var ddpay = var es = // npm install event-streamvar util = var client = 'https://api.dpays.io' var stream = clientblockchain stream
Bundling
The easiest way to bundle ddpay (with browserify, webpack etc.) is to just npm install ddpay
and require('ddpay')
which will give you well-tested (see browser compatibility matrix above) pre-bundled code guaranteed to JustWork™. However, that is not always desirable since it will not allow your bundler to de-duplicate any shared dependencies ddpay and your app might have.
To allow for deduplication you can require('ddpay/lib/index-browser')
, or if you plan to provide your own polyfills: require('ddpay/lib/index')
. See src/index-browser.ts
for a list of polyfills expected.
Share and Enjoy!