Skip to content
🔥 Javascript libraries to work with forge framework
JavaScript Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.makefiles
asset/asset-factory
did
docs
examples
forge
swap
tools
.editorconfig
.eslintignore
.eslintrc.js
.gitattributes
.gitignore
.prettierrc
.travis.yml
CHANGELOG.md
CONTRIBUTION.md
LICENSE
Makefile
README.md
lerna.json
netlify.toml
package.json
version
yarn.lock

README.md

forge-javascript-sdk

Table of Contents

Introduction

lerna docs Gitter

Last updated at 12/13/2019, 6:16:12 AM

Javascript SDK for forge, which is an awesome framework to write distributed blockchain applications.

Packages

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.sendDeclareTx({
  tx: { itx: { 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);

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: 'abcd' });
console.log(message);

Documentation

https://docs.arcblock.io/forge/sdks/javascript/latest/

Contribution

Checkout CONTRIBUTION.md

Compatibility

Forge javascript sdk works with node.js v8.x or above, checkout Travis for status.

Report a Bug?

Bugs and feature requests please create new issues here

License

Copyright 2018-2019 ArcBlock

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You can’t perform that action at this time.