1.0.8 • Published 4 years ago
indra-js v1.0.8
Indra JS
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
- Create Account
- Import Account
- Get Balance
- Transfer Balance
- Transfer Batch ( Transfer balance to many account at the same time )
- 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 Name | Description | Default Value | Example |
---|---|---|---|
type | Account keys are keys that are meant to control funds. They can be either: 'sr25519' or 'ed25519' | sr25519 | type: 'sr25519' |
seed | The 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. | null | seed: '//Alice' |
receiverAddress | The wallet address of the receiver. | null | receiverAddress: 'Bob ' |
amount | Amount to send. | null | amount: '10' |
Contract ERC-20 | |||
abi | The ABI for the WASM code. The ABI is required and stored for future operations such as sending messages. | null | .json file |
address | Address of the Contract. | null | address: 'Bob' |
call_from | Specify 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) | null | call_from: 'Bob' |
License
Apache License 2.0