Hey! These docs are for version 0.18.0, which is no longer officially supported. Click here for the latest version, 0.21.0!

Use DAPI Client Methods

Accessing DAPI client methods via the SDK

Overview

In addition to the SDK methods for interacting with identities, names, contracts, and documents, the SDK also provides direct access to DAPI client methods.

Prerequisites

Code

The following example demonstrates several of the Core DAPI client methods. DAPI client also has several Platform methods accessible via getDAPIClient().platform.*. The methods can be found here in the js-dapi-client repository.

const Dash = require('dash');

const client = new Dash.Client();

async function dapiClientMethods() {
  console.log(await client.getDAPIClient().core.getBlockHash(1));
  console.log(await client.getDAPIClient().core.getBestBlockHash());
  console.log(await client.getDAPIClient().core.getBlockByHeight(1));

  return client.getDAPIClient().core.getStatus();
}

dapiClientMethods()
  .then((d) => console.log('Core status:\n', d))
  .catch((e) => console.error('Something went wrong:\n', e))
  .finally(() => client.disconnect());

📘

Examples using DAPI client to access many of the DAPI endpoints can be found in the DAPI Endpoint Reference section.


Did this page help you?