JSPM

@ocap/sdk

1.19.13
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 635
  • Score
    100M100P100Q93648F
  • License Apache-2.0

Forge javascript SDK packages all-in-one

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ocap/sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    forge-sdk

    styled with prettier docs Gitter

    Forge Javascript SDK packages all in one

    Table of Contents

    Install

    npm i @ocap/sdk
    // OR
    yarn add @ocap/sdk

    Usage

    ES5(commonjs)

    Support Node.js

    const OcapSDK = require('@ocap/sdk');
    
    // Connect to multi endpoints
    OcapSDK.connect('https://test.abtnetwork.io/api', { name: 'test' });
    OcapSDK.connect('https://beta.abtnetwork.io/api', { name: 'beta' });
    
    const sender = OcapSDK.Wallet.fromRandom();
    const receiver = OcapSDK.Wallet.fromRandom();
    
    // Declare on test chain
    await OcapSDK.declare({ moniker: 'sender', wallet: sender }, { conn: 'test' }).then(console.log);
    await OcapSDK.declare({ moniker: 'receiver', wallet: receiver }, { conn: 'test' }).then(console.log);
    
    // Get beta chain info
    OcapSDK.getChainInfo({ conn: 'beta' }).then(console.log);
    
    // Get local chain info
    OcapSDK.getChainInfo({ conn: 'local' }).then(console.log);
    
    // Poke and transfer on test chain
    await OcapSDK.transfer({ to: receiver.address, token: 1, wallet: sender }, { conn: 'test' }).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 OcapSDK from '@ocap/sdk';
    
    OcapSDK.connect('https://test.abtnetwork.io/api', { name: 'test' });
    
    OcapSDK.getChainInfo().then(console.log);
    OcapSDK.declare({
      moniker: 'abcd',
      wallet: OcapSDK.Wallet.fromRandom(),
    }).then(console.log);

    Util

    const OcapSDK = require('@ocap/sdk');
    
    const bn = OcapSDK.Util.fromTokenToUnit(10, 16);
    console.log(bn);

    Wallet

    const OcapSDK = require('@ocap/sdk');
    
    const wallet = OcapSDK.Wallet.fromRandom();
    console.log(wallet.toJSON());

    Message

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

    Packages Included