This is the main class that interact with IOST blockchain and IOST smart contracts to get informations from them.
constructor method is a special method for creating and initializing Blockchain class.
DO NOT  need to initialize by user, user will use Blockchain class by rpc.blockchain。
get chain info from blockchain
Promise returns chainInfo object.
Name Type Description  
net_name String the name of network, such mainnet or testnet protocol_version String the iost protocol version head_block Number head block height head_block_hash String head block hash lib_block Number last irreversible block number lib_block_hash String last irreversible block hash witness_list Array the current witness list  
const  rpc = new  IOST.RPC(new  IOST.HTTPProvider('http://127.0.0.1:30001' ));
rpc.blockchain.getChainInfo().then(console .log);
get block info from blockchain by hash
Name Type Description  
hash String the hash of the block complete Boolean complete means whether including the full transactions and transaction receipts  
Promise returns block object.
Name Type Description  
status String transaction status block Object Block Object  
Name Type Description  
hash String block hash version Number block version parent_hash String parent block hash tx_merkle_hash String transaction merkle tree root hash tx_receipt_merkle_hash String transaction receipt merkle tree root hash number String block number witness String block producer witness time String block timestamp gas_usage String block gas usage tx_count String transaction count transactions Array array of Transaction Object  info Object Info Object  
Name Type Description  
token String token name value Number limit value  
Name Type Description  
mode Number pack mode thread Number transaction execution thread number batch_index Array transaction index of every batch execution  
const  rpc = new  IOST.RPC(new  IOST.HTTPProvider('http://127.0.0.1:30001' ));
rpc.blockchain.getBlockByNum(1 , true ).then(console .log);
get block info from blockchain by num
Name Type Description  
num Number the number of the block complete Boolean complete means whether including the full transactions and transaction receipts  
Promise returns block object. check getBlockByHash 
get account balance
Name Type Description  
name String account name by_longest_chain Boolean get account by longest chain's head block or last irreversible block  
Promise returns balance object.
const  rpc = new  IOST.RPC(new  IOST.HTTPProvider('http://127.0.0.1:30001' ));
rpc.blockchain.getBalance('myaccount' , true ).then(console .log);
get account token721 balance
Name Type Description  
name String account name tokenSymbol String token721 symbol by_longest_chain Boolean get account by longest chain's head block or last irreversible block  
Promise returns balance object.
const  rpc = new  IOST.RPC(new  IOST.HTTPProvider('http://127.0.0.1:30001' ));
rpc.blockchain.getToken721Balance('myaccount' , 'my721Token' , true ).then(console .log);
get token721 metadata
Name Type Description  
token String token name token_id String token id by_longest_chain Boolean get account by longest chain's head block or last irreversible block  
Promise returns metadata object.
Name Type Description  
metadata String metadata  
const  rpc = new  IOST.RPC(new  IOST.HTTPProvider('http://127.0.0.1:30001' ));
rpc.blockchain.getToken721Metadata('symbol' , 'id' , true ).then(console .log);
get token721 owner
Name Type Description  
token String token name token_id String token id by_longest_chain Boolean get account by longest chain's head block or last irreversible block  
Promise returns owner object.
Name Type Description  
owner String metadata  
const  rpc = new  IOST.RPC(new  IOST.HTTPProvider('http://127.0.0.1:30001' ));
rpc.blockchain.getToken721Owner('symbol' , 'id' , true ).then(console .log);
get contract from blockchain
Name Type Description  
id String contract id by_longest_chain Boolean get account by longest chain's head block or last irreversible block  
Promise returns contract object.
Name Type Description  
id String contract id code String contract code language String contract language version String contract version abis Array array of ABI Object   
Name Type Description  
name String contract id args Array abi arguments amount_limit Array array of AmountLimit Object   
get contract storage from blockchain
Name Type Description  
id String contract id key String the key in the StateDB field String get the value from StateDB, field is needed if StateDB[key] is a map.(we get StateDB[key][field] in this case) by_longest_chain Boolean get account by longest chain's head block or last irreversible block  
Promise returns contract result object.
Name Type Description  
data String data  
get account info from blockchain
Name Type Description  
name String account name by_longest_chain Boolean get account by longest chain's head block or last irreversible block  
Promise returns account object.
Name Type Description  
current_total Number current total gas amount transferable_gas Number current transferable gas pledge_gas Number current pledge gas increase_speed Number gas increase speed limit Number account name pledged_info Array array of PledgeInfo Object   
Name Type Description  
pledger String the account who pledges amount Number pledged amount  
Name Type Description  
available Number available ram bytes  
Name Type Description  
name String permission name groups Array array of permission groups items Array array of Item Object  threshold Number permission threshold  
Name Type Description  
id String permission name or key pair id is_key_pair Boolen whether it's a key pair weight Number permission weight permission String permission  
Name Type Description  
name String group name items Array array of Item Object   
Name Type Description  
amount Number balance amount time Number free time  
const  rpc = new  IOST.RPC(new  IOST.HTTPProvider('http://127.0.0.1:30001' ));
rpc.blockchain.getAccountInfo("myaccount" ).then(console .log);