Recent Artilces

JavaScript SDK

JavaScript SDK

← All Topics

iost.js is the JavaScript SDK that is used to interact with the IOST blockchain. It can be used in web browsers and on the NodeJS platform. It can send transactions, view account information, get block data, interface with storage, etc.

Github Repository

Installation – NodeJS Project

  npm install iost

Installation – Content Delivery Network

  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/iost.min.js"></script>

Example Code


const IOST = require('iost')

// use RPC
const rpc = new IOST.RPC(new IOST.HTTPProvider("http://localhost:30001"));
rpc.blockchain.getChainInfo().then(console.log);

// init iost sdk
let iost = new IOST({ // will use default setting if not set
    gasRatio: 100,
    gasLimit: 2000000,
    delay:0,
}, new IOST.HTTPProvider('http://localhost:30001'));

let account = "abc";
let kp = new IOST.KeyPair(/* your private key in type Buffer */);

iost.setPublisher(account, kp);

// send a call
let handler = iost.callABI("iost.token", "transfer", ["iost", "form", "to", "1000.000"]);

handler
    .onPending(console.log)
    .onSuccess(console.log)
    .onFailed(console.log)
    .send()
    .listen(); // if not listen, only onPending or onFailed (at sending tx) will be called

API Calls

Storage


        storage.put(k, v);

        storage.has(k);

        storage.get(k);

        storage.del(k);
  
        storage.mapPut(k, f, v);

        storage.mapGet(k, f);
 
        storage.mapHas(k, f);

        storage.mapKeys(k);
 
        storage.mapLen(k);

        storage.mapDel(k, f);
 
        storage.globalHas(c, k);

        storage.globalGet(c, k);
 
        storage.globalMapGet(c, k, f);

        storage.globalMapHas(c, k, f);
 
        storage.globalMapKeys(c, k);
  
        storage.globalMapLen(c, k);
 

Blockchain

        
        blockchain.deposit(from, amount, "memo");
   
        blockchain.withdraw(to, amount, "memo");
 
        blockchain.blockInfo();
 
        block;

        tx;

        blockchain.txInfo();
 
        blockchain.contextInfo();
 
        blockchain.contractName();

        blockchain.publisher();

        blockchain.receipt(data);

Vote For Us
Vote for IOST Watch and receive Daily IOST reward