electrum-cash: getting started
Introduction
Electrum-cash is a javascript/typescript library for communicating with electrum servers.
This example demonstrates how to install the library with npm
and how to include it in your NodeJS
-based project.
It is possible to use the library in a browser and on other platforms by transpiling with tools like babel
, webpack
and similar, but that is outside the scope of this article.
Requirements
Before you get started, make sure that you have reasonable modern versions of nodejs
and npm
installed by opening a terminal prompt and requesting version information:
$ node -v
v14.4.0
$ npm -v
6.14.5
Installing the library
To install the electrum-cash
library, navigate to your project's root folder and use npm
:
$ cd MyProject/
$ npm install electrum-cash
Import the library into your project
The library supports both CommonJS
and ES2015
, and comes with bindings for TypeScript
.
This example includes the full library but you can also include just the parts you need.
// Include the electrum-cash library using CommonJS.
const ElectrumCash = require('electrum-cash');
// Include the electrum-cash library as an ES2015 module.
import * as ElectrumCash from 'electrum-cash';
Conclusion
As long as you have a modern version of NodeJS
you should be able to add electrum-cash
to your project in just a few minutes.
brilliant