@xazabevo/dapi-client
v0.18.0-dev.3
Published
Client library used to access Xazab DAPI endpoints
Downloads
4
Readme
DAPI Client
Client library used to access Xazab DAPI endpoints
This library enables HTTP-based interaction with the Xazab blockchain and Xazab Platform via the decentralized API (DAPI) hosted on Xazab masternodes.
DAPI-Client
provides automatic server (masternode) discovery using either a default seed node or a user-supplied oneDAPI-Client
maps to DAPI's RPC and gRPC endpoints
Table of Contents
Install
npm install @xazabevo/dapi-client
Usage
Basic
const DAPIClient = require('@xazabevo/dapi-client');
const client = new DAPIClient();
client.core.getStatus().then((coreStatus) => {
console.dir(coreStatus);
});
Custom seed node
Custom seed nodes are necessary for connecting the client to devnets since the client library is unaware of them otherwise.
const DAPIClient = require('@xazabevo/dapi-client');
var client = new DAPIClient({
seeds: [{
host: 'seed-1.evonet.networks.xazab.xyz',
httpPort: 3000,
grpcPort: 3010,
}],
});
client.core.getBestBlockHash().then((r) => {
console.log(r);
});
Note: The seed node shown above (seed-1.evonet.networks.xazab.xyz
) is for the Xazab Evonet testing network.
Custom addresses
Custom addresses may be directly specified in cases where it is beneficial to know exactly what node(s) are being accessed (e.g. debugging, local development, etc.).
const DAPIClient = require('@xazabevo/dapi-client');
var client = new DAPIClient({
dapiAddresses: [
'127.0.0.1:3000:3010',
'127.0.0.2:3000:3010',
],
});
client.core.getBestBlockHash().then((r) => {
console.log(r);
});
Command specific options
DAPI Client options can be passed directly to any command to override any predefined client options and modify the client's behavior for that specific call.
const DAPIClient = require('@xazabevo/dapi-client');
// Set options to direct the request to a specific address and disable retries
const options = {
dapiAddresses: ['127.0.0.1'],
retries: 0,
};
client.core.getBestBlockHash(options).then((r) => {
console.log(r);
});
Documentation
More extensive documentation available at https://xazabevo.github.io/js-dapi-client/.
Contributing
Feel free to dive in! Open an issue or submit PRs.
License
MIT © Dash Core Group, Inc.