https://medium.com/coinmonks/how-to-use-eosjs-api-1-770b037b22ad

https://blog.csdn.net/mongo_node/article/details/82751747

https://github.com/EOSIO/eosjs-api/blob/master/docs/api.md#eos--object

Be careful : Because each BP Endpoints have different speeds and reliability , It is recommended to use the most suitable one for you BP.

Greetings, this is Dongjun Kwon from ITAM Network. In a previous post on ‘Getting Started with EOSJS,’ we went over how to use EOSJS. In this post, we will be going over the commonly used APIs on EOSJS and testing them.

Click here to see the list of APIs

Preparation

We will be making all codes available to use. In order to make useable, preparation is needed. The preparations are as follows:

  1. Node.js
  2. EOSJS

Please install the above two and put the following at the top of the javascript file.

After you have done this, code the api examples below and run javascript with node.js to get the value.

Because each BP Endpoint has different speed and/or reliability, we recommend you use the BP that is most suitable for you.

getBlock(blockNumOrId)

Used to bring the information of an applicable block.

params

Code

Result

{ timestamp: '2018-06-08T08:08:08.500',
producer: '',
confirmed: 1,
previous:
'0000000000000000000000000000000000000000000000000000000000000000',
transaction_mroot:
'0000000000000000000000000000000000000000000000000000000000000000',
action_mroot:
'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
schedule_version: 0,
new_producers: null,
header_extensions: [],
producer_signature:
'SIG_K1_111111111111111111111111111111111111111111111111111111111111111116uk5ne',
transactions: [],
block_extensions: [],
id:
'00000001405147477ab2f5f51cda427b638191c66d2c59aa392d5c2c98076cb0',
block_num: 1,
ref_block_prefix: 4126519930 }

To see the activities that took place in the applicable block, look at the transactions. To view transactions, do the following:

If you look at the transactions by using the above value, there are actions. By looking at the actions, you can have a deeper look at the activities that took place.

getAccount(accountName)

Used to get an EOS account’s information.

Params

Code

Result

{ account_name: 'itamnetwork1',
head_block_num: 8516805,
head_block_time: '2018-07-30T07:34:52.500',
privileged: false,
last_code_update: '1970-01-01T00:00:00.000',
created: '2018-07-09T02:24:58.500',
core_liquid_balance: '12.6131 EOS',
ram_quota: 14976,
net_weight: 201000,
cpu_weight: 10401000,
net_limit: { used: 1679786, available: 11108657, max: 12788443 },
cpu_limit: { used: 7950353, available: 6356380, max: 14306733 },
ram_usage: 10934,
permissions:
[ { perm_name: 'active', parent: 'owner', required_auth: [Object] },
{ perm_name: 'owner', parent: '', required_auth: [Object] } ],
total_resources:
{ owner: 'itamnetwork1',
net_weight: '20.1000 EOS',
cpu_weight: '1040.1000 EOS',
ram_bytes: 14976 },
self_delegated_bandwidth:
{ from: 'itamnetwork1',
to: 'itamnetwork1',
net_weight: '0.1000 EOS',
cpu_weight: '0.1000 EOS' },
refund_request: null,
voter_info:
{ owner: 'itamnetwork1',
proxy: '',
producers: [],
staked: 4000,
last_vote_weight: '0.00000000000000000',
proxied_vote_weight: '0.00000000000000000',
is_proxy: 0 } }

I’ll explain some of the above result values.

  1. account_name: as you all probably already know, it is the EOS account name.
  2. ram_quota: the amount of RAM I hold, measured in byte.
  3. net_limit: the total amount of net, useable net, and used net of an account, measured in byte.
  4. cpu_limit: the total amount of CPU, available CPU, and used CPU of an account, measured in us.
  5. ram_usage: amount of RAM used of an account, measured in byte.
  6. total_resources: the EOS of the resource allocated to me.
  7. self_delegated_bandwidth: the information I delegated to myself.
  8. voter_info: information regarding votes. Keep an eye on the ‘staked’ part, which shows the amount I staked. More specifically, it is the value that includes what I delegated to myself and what others delegated.

getKeyAccounts(publicKey)

Gets the accounts of a public key.

Params

Code

Result

{ account_names: [ 'itamnetwork1' ] }

It is possible to make many accounts with one EOS public key. This is why the value of account_name is an array in the form of a string.

getCurrencyBalance(code, account, symbol)

Gets the Token corresponding to the symbol of a code.

Params

Code

Result

[ '12.6131 EOS' ]

If you look at the result value, you can see an array in the form of a string. This is because there could be tokens with many different symbols in the account. On the EOS testnet, Jungle Net, if you search eosio.token excluding symbol, you can see 2 tokens.

getCurrencyStats(code, symbol)

Get the token information of the symbol.

Params

Code

Result

{ EOS:
{ supply: '1006148640.3388 EOS',
max_supply: '10000000000.0000 EOS',
issuer: 'eosio' } }

Below are the descriptions of the result values.

  1. supply: the number of tokens supplied currently.
  2. max_supply: the total number of tokens.
  3. issuer: the issuer

Conclusion

We went over the 5 most frequently used EOSJS APIs. There are still numerous APIs that we have not covered, and I am planning to go over these in a later post. Thank you.

The above examples can be found on github.


Subscribe to ITAM Network and receive the latest info.

Visit the ITAM Network Telegram to communicate regarding ITAM Network and Blockchain. Join by clicking the link below!

How to use EOS.JS Of API More articles about

  1. Native JS actual combat : I wrote about playing games , Side note JS Of API The game of

    This is Su Fu's original article , Reprint please indicate the source : Sufu CNblog:http://www.cnblogs.com/susufufu/p/5878913.html This program [ Playing games , Side note JS Of API] It's my ...

  2. [ Reprint ]fullPage.js chinese api Configuration parameters ~

    fullPage.js chinese api Configuration parameters Options type The default value is explain verticalCentered character string true Is the content vertically centered resize Boolean value false Does the font scale as the window zooms ...

  3. AngularJS to grant authorization + Node.js REST api

    The author is such a loser , He knows everything I don't know . Authentication with AngularJS and a Node.js REST api A few months ago , I began to think AngularJS It's like a bull , On ...

  4. Node.js RESTful API

    What is? REST framework ? REST Represents a representative state transfer .REST It's based on Web Standard Architecture , And use HTTP agreement . It's all about resources , Each component is a resource and a resource is used by a common interface HTTP The standard method of obtaining ...

  5. Practical Node.js (2018 edition ) The first 8 Chapter :Building Node.js REST API Servers

    Building Node.js REST API Servers with Express.js and Hapi Modern-day web developers use an architec ...

  6. jQuery- Full screen scrolling plug in 【fullPage.js】API Summary of usage

    jQuery- Full screen scrolling plug in [fullPage.js]API Summary of usage   jQuery- Full screen scrolling plug in fullPage.js Summary of usage author github And download address :https://github.c ...

  7. Node.js Commonly used API

    Node.js v6.11.2  Documentation( Official documents ) Buffer Prior to the introduction of TypedArray in ECMAScript 20 ...

  8. Ten words Node.js REST API Best practices ( On )

    Included for use , The modification and reprint have been authorized by Tencent cloud original text :10 Best Practices for Writing Node.js REST APIs We will write through this article Node.js REST API The best ...

  9. Ten words Node.js REST API Best practices ( Next )

    Included for use , The modification and reprint have been authorized by Tencent cloud 5. To you Node.js REST API Do a black box test To test your REST API One of the best ways is to treat them like black boxes . Black box testing is a test method , In this way, you don't need to know ...

Random recommendation

  1. 【 turn 】nexus Maven Environment building

    http://www.cnblogs.com/quanyongan/archive/2013/04/24/3037589.html Why build nexus Private clothes , The reason is simple , Some companies don't provide Internet to the project team ...

  2. show master status empty Solution

    The following MySQL error might occur if you are using MySQL replication and binary logs. mysql> ...

  3. IoC/DI

    From:http://jinnianshilongnian.iteye.com/blog/1471944 I am right. IoC/DI The understanding of the Blog classification : spring gossip IoCDI  IoC IoC: Inv ...

  4. Simple javaEE Mind mapping

  5. VirtualBox Change the mouse switch hotkey between host and virtual machine

    VirtualBox Hotkeys for mouse switching between host and virtual machine yes Right Ctrl. Generally used to VM Ware I'm not used to it , So how to change VirtualBox Mouse switch hotkeys ? 1. Click on the menu bar    management --&g ...

  6. linux Command learning -3-sysctl

    sysctl Kernel variable configuration Usage: sysctl [options] [variable[=value] ...]   NAME sysctl - configure kernel parame ...

  7. windows redis Auto start

    start.bat D: D:\dev\redis- redis-server.exe redis.conf redis.vbs createobject( after , hold start.bat Put it in redi ...

  8. Windows service BAT command - install 、 uninstall 、 start-up 、 stop it

    1. Installation services %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe D:\WiseMES\MES.WindowsService ...

  9. OLE Tool suite analysis OFFICE Macro malicious samples

    zero . The introduction :OLE Introduction of tool suite OLE Tool suite is a tool for OFFICE Document development has a powerful analysis of a set of tools . This paper mainly introduces the concept based on Python2.7 Of OLEtools Installation and use . (1)Python Version requirement ...

  10. Power Designer Reverse engineering import Oracle surface , Turn to model and annotate

    1. open PowerDesigner —— file ——Reverse Engineer——DataBase 2. Select the database version you want to connect to , What is used here is oracle version 11g. 3. Click on the red area , ...