gex-client-js¶
Galactic Exchange client tools.
You can use this library to develop browser and Node.js applications that use Galactic Exchange.
Warning
Library is still at a very early stage, so API may change significantly between minor releases (like 0.2 -> 0.3)
Info
API for early versions (0.1 - 0.1.27) could be found in GitHub README
Getting Started¶
Installation¶
NPM¶
npm install @galacticexchange/gex-client-js
Yarn¶
yarn add @galacticexchange/gex-client-js
Initialization¶
The package includes both non-minified version and a minified version.
For web browsers you will typycally use non-minified version for development and minified version for production mode.
For Node.js projects you will need to use non-minified version.
Require library (minified)¶
const gex = require('@galacticexchange/gex-client-js');
Require library (non-minified)¶
const gex = require('@galacticexchange/gex-client-js/src/index');
Init library¶
Init with web socket¶
Find out the IP addess and port of the Ethereum blockchain node that you want to connect to.
Note that the standard port is 8546. Use the address and the port to init the library as illustrated in the example below.
Note: your blockchain node needs to have WebSockets enabled.
let ip = '51.0.1.99'; let port = '8546'; gex.init(ip, port);
Init with web3Provider¶
If you wanna use custom web3 provider (like Metamask)
gex.initWithProvider(web3Provider);
Init with 2 providers (node + custom)¶
Warning
This is temporary solution to use Metamask & receive blockchain events at the same time. See API Specification -> Events for more details.
let ip = '51.0.1.99'; let port = '8546'; gex.initBothProviders(ip, port, web3Provider);