Polymesh SDK
The Polymesh SDK is a TypeScript/JavaScript library that provides a simple, powerful interface for building applications and integrations on the Polymesh blockchain. It abstracts away blockchain complexity and exposes a feature-rich, user-friendly API for developers.
Features
- High-level, type-safe API for interacting with Polymesh
- Supports asset creation, identity management, compliance, settlements, and more
- Works in Node.js and browser environments
- Flexible signing manager system for secure key management
- Extensive documentation and code examples
📖 Full SDK API Reference
Getting Started
1. Install the SDK
- npm
- Yarn
- pnpm
npm install @polymeshassociation/polymesh-sdk
yarn add @polymeshassociation/polymesh-sdk
pnpm add @polymeshassociation/polymesh-sdk
Note: It is highly recommended to use npm, yarn, or pnpm. Other package managers may not support all dependency overrides.
2. Initialize the SDK Client
You'll need a Polymesh node endpoint (e.g. wss://mainnet-rpc.polymesh.network/
) and a signing manager if you wish to submit transactions.
import { Polymesh } from '@polymeshassociation/polymesh-sdk';
import { LocalSigningManager } from '@polymeshassociation/local-signing-manager';
async function run() {
const signingManager = await LocalSigningManager.create({
accounts: [
{ mnemonic: '//Alice' },
// ...add more accounts as needed
],
});
const polyClient = await Polymesh.connect({
nodeUrl: 'wss://mainnet-rpc.polymesh.network/',
signingManager,
});
// Interact with the chain using polyClient
}
For browser apps, use the Browser Extension Signing Manager to connect to the Polymesh Wallet extension.
3. Example: Create an Asset
const createAssetProc = await polyClient.assets.createAsset({
name: 'My Asset',
ticker: 'TICKER',
});
const newAsset = await createAssetProc.run();
4. Example: Read Data
const assetsPage = await polyClient.assets.get({ size: new BigNumber(20) });
const asset = assetsPage.data[0];
const assetDetails = await asset.details();
console.log('asset details:', assetDetails);
Related Pages
- Signing Managers: Secure and flexible key management for the SDK
- Polymesh Types: Type definitions and low-level integration
- SDK Examples Repository: Example scripts and usage patterns
- Full SDK API Reference