@beon/jssdk

1.0.10 • Public • Published

A BeOn side chain of Ethereum network. The gateway is currently supporting the following functionalities:

  • ERC20 Token creation
  • ETH/ERC20 Token deposit
  • ETH/ERC20 Token transfer
  • ETH/ERC20 Token withdraw
  • Transaction confirmation
  • Balance checking

This document details functions that available within the gateway which can be called using jsonrpc.

BeOn chain also provides the JSSDK to interact with the gateway. Examples are provided below. Please note that this is an ongoing development of the side chain. We appreciate any issues reported.

Deployments

Rinkeby

Node Gateway: https://rinkeby.beon.network/
Root Contract Address: 0x62f23c4659bc327833c2c7bb4abe2cf2fdca9fe2 Block Explorer and DApp interface: https://dapp.beon.network/

Usages

Install beon jssdk

npm install @beon/jssdk

Setup SDK

const BeOnSDK = require("@beon/jssdk");
let sdk = new BeOnSDK({
  host: "https://rinkeby.beon.network/",
  networkId: "4",
  provider: `https://rinkeby.infura.io/${process.env.INFURA_APIKEY}`,
  gas: 7000000
});

GETTING INFURA APIKEY

Get Balances

let address = "0x...";
sdk.getBalances(address).then(console.log).catch(console.error);

Create Token

let account = "0x...";
let key = "0x...";
let initialAmount = 0;
let tokenName = "BeOn";
let decimalUnits = 18;
let tokenSymbol = "BEO";

sdk.createToken({
  account,
  key
}, {
  initialAmount,
  tokenName,
  decimalUnits,
  tokenSymbol
}).then((response)=>{
  let tokenAddress = response.result.result.logs[0].address;  
}).catch(console.error);

Mint Token

sdk.mintToken({
  account,
  key
}, {
  tokenAddress: "0x...",
  to: "0x...",
  amount: "10000000000000000",
}).then(console.log).catch(console.error);

Deposit

sdk.deposit({
  account,
  key
}, {
  token: "0x0", // token address. 0x0 is ETH.
  amount: "1" // in ether
}).then(console.log).catch(console.error);

Transact

sdk.transfer({
  account,
  key
}, {
  token: "0x0", // token address. 0x0 is ETH.
  to: "0x...",
  amount: "0.01" // in ether
}).then(console.log).catch(console.error);

Confirm Transaction

sdk.confirmTx({
  account,
  key
}, {
  blkNum: "100000",
  txIndex: "0"
}).then(console.log).catch(console.error);

Withdraw

sdk.withdraw({
  account: "0x...",
  key: "0x..."
}, {
  blkNum: "200000",
  txIndex: "1",  
  oIndex: "0"
}).then(console.log).catch(console.error);

GENERATE ETHEREUM ACCOUNT

let web3 = new Web3(new Web3.providers.HttpProvider(`https://rinkeby.infura.io/${process.env.INFURA_APIKEY}`));
let account = web3.eth.accounts.create();

INSTALL METAMASK AND CREATE RINKEBY ACCOUNT

FUND THE RINKEBY ACCOUNT

Readme

Keywords

none

Package Sidebar

Install

npm i @beon/jssdk

Weekly Downloads

1

Version

1.0.10

License

ISC

Unpacked Size

1.77 MB

Total Files

14

Last publish

Collaborators

  • steerapi