Coder Social home page Coder Social logo

isabella232 / polymesh-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from polymeshassociation/polymesh-sdk

0.0 0.0 0.0 13.92 MB

Feature rich and user friendly typescript package to interact with the Polymesh blockchain

License: Apache License 2.0

Shell 0.01% JavaScript 0.54% TypeScript 99.45%

polymesh-sdk's Introduction

semantic-release js-semistandard-style Types npm License Coverage Github Actions Workflow Sonarcloud Status Issues

@polymathnetwork/polymesh-sdk

Polymesh version

This release is compatible with Polymesh v4.1.0

Getting Started

Purpose

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.

Before moving on

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.

Documentation

Token Studio SDK Walkthrough:

https://developers.polymath.network/token-studio-api-walkthrough/

Polymesh SDK API Reference:

https://developers.polymath.network/polymesh-sdk-api-reference/

How to use

Installation

npm i @polymathnetwork/polymesh-sdk --save

Or, if you're using yarn

yarn add @polymathnetwork/polymesh-sdk

NOTE if using TypeScript the compiler option "skipLibCheck" should be set to true in your tsconfig.json file

Initializing the client

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 '@polymathnetwork/polymesh-sdk';
import { LocalSigningManager } from '@polymathnetwork/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 the SigningManager 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 @polymathnetwork/browser-extension-signing-manager

import { Polymesh } from '@polymathnetwork/polymesh-sdk';
import { BrowserExtensionSigningManager } from '@polymathnetwork/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
}

polymesh-sdk's People

Contributors

dependabot[bot] avatar hlminh2000 avatar monitz87 avatar onigiri-x avatar pabloruiz55 avatar polymath-eric avatar prashantasdeveloper avatar shuffledex avatar victorvicente avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.