Dock SDK


Dock is a blockchain built using Substrate and uses polkadot-js for interacting with the chain. The current version of Dock supports creating and managing DIDs compliant with the W3C spec and verifiable credentials compliant with the Verifiable Credentials Data Model 1.0. This SDK is meant to build client-side or server side javascript applications.


  • Install from npm with npm install @docknetwork/sdk or yarn add @docknetwork/sdk
  • Or clone from github and run
    1. yarn install
    2. yarn build


Once the SDK has been installed, import the Dock API object as

import { DockAPI } from '@docknetwork/sdk/api';

To construct the API object

const dock = new DockAPI();

To make the API object connect to the node call init method. This method accepts the Websocket RPC endpoint of the node is needed. Say you have it in rpcEndpoint. It also accepts a Polkadot-js keyring as well.

await dock.init(rpcEndpoint, keyring);

To disconnect from the node

await dock.disconnect();

To set the account used in sending the transaction and pay fees, call setAccount with the polkadot-js account

// the `account` object might have been generated as
const account = dock.keyring.addFromUri(secretURI);
// Set the account to pay fees for transactions

To get the account, call getAccount


To send a transaction, use the signAndSend on the DockAPI object

const res = await dock.signAndSend(transaction);

For interacting with the DID module, i.e. creating, updating and removing them, get the didModule with did getter

const didModule = dock.did;

Similarly, for the revocation module, get the revocationModule with revocation getter

const revocationModule = dock.revocation;