Introduction

Purpose

The Polymesh SDK walk-through focuses primarily on the implementation of Polymath's Token Studio on Polymesh. Token Studio is a Polymath dApp that allows users to create and manage security tokens using the Polymesh blockchain's architecture.

The goal of the SDK is to abstract away from the rust-based development of Polymesh and allow external developers to use a typescript-based SDK to build and integrate Token Studio functionality without the burden of searching through a technical document.

Before continuing

This document assumes you are already familiar with Security Tokens in general and Polymath as well as Polymesh in particular.

Technical Pre-requisites

In order to use the Polymath SDK, you must install node (version 10) and npm. The library is written in typescript, but can also be used in plain javascript. This document will assume you are using typescript, but the translation to javascript is very simple.

Get Started

Installation

npm i @polymathnetwork/polymesh-sdk --save

Or, if you're using yarn

yarn add @polymathnetwork/polymesh-sdk

Initializing the client

Before you can start registering Tickers and creating Security Tokens, you have to connect the Polymesh SDK client to a Polymesh node. This is a pretty straightforward process:

import { Polymesh } from '@polymathnetwork/polymesh-sdk';
async function run() {
const polyClient = await Polymesh.connect({
nodeUrl: 'https://some-node-url.com',
accountSeed: 'YOUWISH',
});
// do stuff with the client
}

Here is an overview of the parameters passed to the connect function:

  • nodeUrl is a URL that points to a running Polymesh node

  • accountSeed is the seed (akin to a private key) of the account that will be performing transactions

NOTE: if using the SDK on a browser environment (i.e. with the Polymesh wallet browser extension), there is no need to provide the account seed. Instead, you pass a Keyring object that contains the address, and a signer for that address (which you would typically get from the wallet extension)

import { Polymesh, Keyring } from '@polymathnetwork/polymesh-sdk';
async function run() {
const keyring = new Keyring();
keyring.addFromAddress(accountAddress);
const signer = getSignerFromExtension(); // this is not an existing function, how you get this depends on the extension
const polyClient = await Polymesh.connect({
nodeUrl: 'https://some-node-url.com',
keyring,
signer,
});
// do stuff with the client
}

Obtaining POLYX

POLYX is the Polymesh network's protocol token that can be used to pay network fees and protocol fees. As Polymesh is only available on the Alcyone testnet, POLYX can only be acquired via the POLY Upgrade bridge. Please follow the instructions throughout the POLY Upgrade bridge to successfully upgrade your POLY from Kovan to POLYX on Polymesh.

A few notes on obtaining POLYX:

  • You will need the Metamask browser extension and an account with some KETH (Kovan ETH). You can request KETH from a faucet here.

  • You will need a Polymesh-compatible wallet and ID. The easiest way to set this up is to download the Polymesh Testing Wallet extension. Remember to store your mnemonic seed as you will need it when testing your project.

  • POLYX can only be sent between Polymesh addresses assigned to verified IDs. When you go through the Upgrade Bridge, you will be directed to a page to verify your Polymesh ID. During this process you will be assigned a DID (Decentralized Identifier, as standardized by the W3C foundation) and given a Customer Due Diligence ("CDD") attestation by a network approved provider. Once you have a DID with a CDD attestation.

Extra Resources

Token Studio UI (This is our implementation of the Polymesh SDK)

Polymesh whitepaper

Intro to Polymath

The New and Improved Token Studio