npm

Need private packages and team management tools?Check out npm Orgs. »

@arcblock/forge-sdk

1.0.0 • Public • Published

forge-sdk

styled with prettier docs Gitter

Forge Javascript SDK packages all in one

Table of Contents

Install

npm i @arcblock/forge-sdk
// OR
yarn add @arcblock/forge-sdk

Usage

ES5(commonjs)

Support Node.js

const ForgeSDK = require('@arcblock/forge-sdk');
 
// Connect to multi endpoints
ForgeSDK.connect('https://test.abtnetwork.io/api', { name: 'test' });
ForgeSDK.connect('https://zinc.abtnetwork.io/api', { name: 'zinc' });
ForgeSDK.connect('tcp://127.0.0.1:28210', { name: 'local' });
 
// Declare on test chain
ForgeSDK.declare({
  moniker: 'abcd',
  wallet: ForgeSDK.Wallet.fromRandom(),
}).then(console.log);
 
// Get zinc chain info
ForgeSDK.getChainInfo({ conn: 'zinc' }).then(console.log);
 
// Get local chain info
ForgeSDK.getChainInfo({ conn: 'local' }).then(console.log);

ES6

If you want to support both node.js and browser, please use lite version And the lite version only supports http connections

import ForgeSDK from '@arcblock/forge-sdk/lite';
 
ForgeSDK.connect('https://test.abtnetwork.io/api', { name: 'test' });
 
ForgeSDK.getChainInfo().then(console.log);
ForgeSDK.declare({
  moniker: 'abcd',
  wallet: ForgeSDK.Wallet.fromRandom(),
}).then(console.log);

Util

const ForgeSDK = require('@arcblock/forge-sdk');
 
const bn = ForgeSDK.Util.fromTokenToUnit(10, 16);
console.log(bn);

Wallet

const ForgeSDK = require('@arcblock/forge-sdk');
 
const wallet = ForgeSDK.Wallet.fromRandom();
console.log(wallet.toJSON());

Message

const ForgeSDK = require('@arcblock/forge-sdk');
 
const message = ForgeSDK.Message.createMessage('Transaction', {
  from: 'xxx',
  nonce: 1234,
  itx: {},
});
console.log(message);

Packages Included

install

npm i @arcblock/forge-sdk

Downloadsweekly downloads

817

version

1.0.0

license

Apache-2.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability