-
Notifications
You must be signed in to change notification settings - Fork 11
Home
This release is compatible with Polymesh v6.x.x
The Polymesh SDK's main goal is to provide external developers with a set of tools that will allow them to build powerful applications that interact with the Polymesh protocol. It focuses on abstracting away all the complexities of the Polymesh blockchain and expose a simple but complete interface. The result is a feature-rich, user-friendly node.js library.
This document assumes you are already familiar with Security Tokens in general and Polymath as well as Polymesh in particular.
In order to use the Polymath SDK, you must install node (version 14) 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.
Token Studio SDK Walkthrough:
https://developers.polymath.network/token-studio-api-walkthrough/
Polymesh SDK API Reference:
https://github.com/PolymeshAssociation/polymesh-sdk/wiki
npm i @polymeshassociation/polymesh-sdk --save
Or, if you're using yarn
yarn add @polymeshassociation/polymesh-sdk
Or, if using pnpm
pnpm add @polymeshassociation/polymesh-sdk
NOTE it is highly recommended that you use one of these three package managers. This project uses package resolutions/overrides to pin certain problematic dependencies, and these are only supported by the aforementioned package managers. Using a different package manager may result in unexpected behavior
NOTE if using TypeScript the compiler option "skipLibCheck" should be set to true in your tsconfig.json file
Before you can start registering Tickers and creating Assets, you have to connect the Polymesh SDK client to a Polymesh node. This is a pretty straightforward process:
import { Polymesh } from '@polymeshassociation/polymesh-sdk';
import { LocalSigningManager } from '@polymeshassociation/local-signing-manager';
async function run() {
const signingManager = await LocalSigningManager.create({
accounts: [
{
seed: 'YOU_WISH',
},
],
});
const polyClient = await Polymesh.connect({
nodeUrl: 'wss://some-node-url.com',
signingManager,
});
// 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 -
signingManager
is an object that complies with theSigningManager
interface. It holds the Accounts capable of signing transactions, and the signing logic itself. In this example,LocalSigningManager
is a simple signing manager that holds private keys in memory and signs with them
NOTE: if using the SDK on a browser environment (i.e. with the Polymesh wallet browser extension), you would use the BrowserExtensionSigningManager
provided by @polymeshassociation/browser-extension-signing-manager
import { Polymesh } from '@polymeshassociation/polymesh-sdk';
import { BrowserExtensionSigningManager } from '@polymeshassociation/browser-extension-signing-manager';
async function run() {
const signingManager = await BrowserExtensionSigningManager.create('MY_APP_NAME'); // The Polymesh wallet extension will ask the user to authorize MY_APP_NAME for access
const polyClient = await Polymesh.connect({
nodeUrl: 'wss://some-node-url.com',
signingManager,
});
// do stuff with the client
}
Entities
- Account
- Asset
- Authorization Request
- Checkpoint
- Checkpoint Schedule
- Corporate Action
- Corporate Action Base
- Custom Permission Group
- Default Portfolio
- Default Trusted Claim Issuer
- Dividend Distribution
- Entity
- Identity
- Instruction
- Known Permission Group
- Metadata Entry
- Multi Sig Proposal
- Numbered Portfolio
- Offering
- Permission Group
- Portfolio
- Subsidies
- Subsidy
- Ticker Reservation
- Venue
- Authorizations
- Types