1.0.8 • Published 4 years ago

indra-js v1.0.8

Weekly downloads
14
License
Apache-2.0
Repository
github
Last release
4 years ago

Indra JS

logo

Selendra javascript SDK for intergration with selendra.

Getting Started

Table of Contents

Installation

  • with Npm
npm install indra-js
  • with Yarn
yarn add indra-js

Feature

  1. Create Account
  2. Import Account
  3. Get Balance
  4. Transfer Balance
  5. Transfer Batch ( Transfer balance to many account at the same time )
  6. Transaction with ERC-20
  • Approve
  • Transfer
  • TransferFrom
  • Allowance
  • BalanceOf
  • Total Supply

Usage

  • Import
const { CreateAccount, ImportAccount, TransferBalance } = require('indra-js');
  • Create Account
CreateAccount({
   type
}).then((res) => {
   console.log(res.mnemonic, res.pair);
})
  • Import Account
ImportAccount({
   type
}).then((res) => {
   console.log(res.pair);
})
  • Get Balance
GetBalance({
   address
}).then((res) => {
   console.log(res.balances)
})
  • TransferBalance
TransferBalance({
   seed,
   receiverAddress, 
   amount
}).then((res) => {
   console.log(res.hash);
})
  • TransferBatch
TransferBatch({
   seed,
   data: [
      { receiverAddress: '', amount: '' }
   ]
}).then((res) => {
   console.log(res.hash);
})

Contract ERC-20

  • Approve
const { Approve } = require('indra-js')
Approve({
   abi,
   address, 
   call_from,
   spender,
   value
}).then((res) => {
   console.log(res.hash);
})
  • Transfer
const { Transfer } = require('indra-js')
Transfer({
   abi,
   address, 
   call_from,
   to,
   value
}).then((res) => {
   console.log(res.hash);
})
  • TransferFrom
const { TransferFrom } = require('indra-js')
TransferFrom({
   abi,
   address, 
   call_from,
   from,
   to,
   value
}).then((res) => {
   console.log(res.hash);
})
  • Allowance
const { Allowance } = require('indra-js')
Allowance({
   abi,
   address, 
   call_from,
   owner,
   spender
}).then((res) => {
   console.log(res.allowance);
})
  • BalanceOf
const { BalanceOf } = require('indra-js')
BalanceOf({
   abi,
   address, 
   call_from,
   owner
}).then((res) => {
   console.log(res.balanceOf);
})
  • Total Supply
const { TotalSupply } = require('indra-js')
TotalSupply({
   abi,
   address, 
   call_from
}).then((res) => {
   console.log(res.hash);
})

User Guide

Props

Prop NameDescriptionDefault ValueExample
typeAccount keys are keys that are meant to control funds. They can be either: 'sr25519' or 'ed25519'sr25519type: 'sr25519'
seedThe seed is your key to the account. Knowing the seed allows you, or anyone else who knows the seed, to re-generate and control this account.nullseed: '//Alice'
receiverAddressThe wallet address of the receiver.nullreceiverAddress: 'Bob '
amountAmount to send.nullamount: '10'
Contract ERC-20
abiThe ABI for the WASM code. The ABI is required and stored for future operations such as sending messages.null.json file
addressAddress of the Contract.nulladdress: 'Bob'
call_fromSpecify the user account to use for the contract call and fees will be deducted from this account.(Approve, Transfer, TransferFrom: 'call_from' must be a rawSeed)nullcall_from: 'Bob'

License

Apache License 2.0