Table of Contents
- Table of Contents
- Introduction
- Packages
- Install
- Documentation
- Contribution
- Compatibility
- Report a Bug?
- License
Introduction
Last updated at 10/10/2019, 2:00:48 AM
Javascript SDK for forge, which is an awesome framework to write distributed blockchain applications.
Packages
- @arcblock/did
- @arcblock/did-auth
- @arcblock/did-util
- @arcblock/forge-config
- @arcblock/forge-message
- @arcblock/forge-proto
- @arcblock/forge-sdk
- @arcblock/forge-util
- @arcblock/forge-wallet
- @arcblock/graphql-client
- @arcblock/grpc-client
- @arcblock/mcrypto
- @arcblock/tcp-server
- @arcblock/tx-util
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.