Giter Site home page Giter Site logo

onebtc-js's Introduction

one-btc sdk

Install instructions

NPM:

npm i onebtc.sdk --save

Yarn

yarn add onebtc.sdk

How to use

1. Init SDK instance

import * as onebtcSdk from 'onebtc.sdk';

const onebtcClient = await onebtcSdk.createClientWeb3({
  nodeURL: 'https://api.s0.b.hmny.io',
  btcNodeUrl: 'https://btc2.test.hmny.io',
  contractAddress: '0x2a9B7F9013E701AA71fE050eA9686BbB49E0D105',
  chainId: 2,
  gasLimit: 6721900,
});

1.1 Add account

const PRIVATE_KEY = 'some_private_key';
await onebtcClient.setAccount(PRIVATE_KEY);

2. Request issue

const VAULT_ADDRESS = '0x498554d79612C76d630c613cA5AD143FeE06ccF2';
onebtcClient.requestIssue(10000, VAULT_ADDRESS);

3. Request redeem

const VAULT_ADDRESS = '0x498554d79612C76d630c613cA5AD143FeE06ccF2';
onebtcClient.requestRedeem(10000, VAULT_ADDRESS);

Dashboard API

Init dashboard client

import { DashboardApi, Network } from 'onebtc.sdk/lib/dashboard-api';

export const dashboardClient = new DashboardApi({
  dashboardUrl: 'https://dashboard.btc.test.hmny.io',
  btcNodeUrl: config.bitcoin.btcNodeUrl.testnet,
  network: Network.TESTNET,
});

Load issue

const issueId = '60223755045874313250033704538578944141691614323714641306215289094834832886161'
dashboardClient.loadIssue(issueId).then((issue) => {
  console.log('### issue', issue);
});

Load redeem

const redeemId = '60223755045874313250033704538578944141691614323714641306215289094834832886161'
dashboardClient.loadRedeem(issueId).then((issue) => {
  console.log('### issue', issue);
});

onebtc-js's People

Contributors

ahiipsa avatar potvik avatar

Watchers

 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.