Socket
Socket
Sign inDemoInstall

@kyber.network/reserve-sdk

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kyber.network/reserve-sdk

JavaScript Reserve SDK


Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

reserve-sdk.js

Build Status npm version Document

Reserve SDK library provides convenient methods to create and operate a KyberNetwork reserve. This package is desinged to work for both client and server side JavaScript application.

Warning: This is pre-released software, use it at your own risk.

Installation

Install the package with:

npm install --save @kyber.network/reserve-sdk

Documentation

See the Reserve SDK.s docs.

Usage

Creating New Contract

Deploying a new KyberNetwork will create a number of smart contracts. The returned addresses should be saved to persistent storage to use in operation later.

Deployment requires a Ethereum node provider and an account.

Example for server side JavaScript application.

// requires a Ethereum Remote Node Provider likes: infura.io, etherscan.io...
const provider = new Web3.providers.HttpProvider('ethereum-node')
const dpl = new Deployer(provider)

// initialize account from private key
const account = dpl.web3.eth.accounts.privateKeyToAccount('private-key')
// initialize account from keystore file
// const account = dpl.web3.eth.accounts.decrypt(fs.readFileSync(), "your-keystore-passphrase");

dpl.web3.eth.accounts.wallet.add(account)

let addresses;
(async () => addresses = await dpl.deploy(account))()

console.log(addresses)

Example for client side Javascript application, using Metamask.

if (typeof window === "undefined" && typeof window.web3 === "undefined") {
  throw new Error("metamask is not installed");
}

const dpl = new Deployer(window.web3.currentProvider);
(async () => {
  const account = (await web3.eth.getAccounts())[0];
  await dpl.deploy(account);
})();

Reserve Operations

The deployed contract addresses will be used for creating a Reserve instance to interact with reserver smart contracts.

const reserve = new Reserve(provider, addresses);
(async () => {
  // admin operations
  await reserve.enableTrade();
  await reserve.disableTrade();
  await reserve.setRate(account, rates, 1000);
})();

Please consult documentation for detail operation instructions.

Development

Run all tests:

$ npm install
$ npm test

Format codes:

$ npm run format

Generate documentation:

$ npm run doc

FAQs

Package last updated on 31 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc