怎样使用EOS.JS的API
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
注意:由于每个BP端点具有不同的速度及可靠性,建议使用最适合您的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:
- Node.js
- 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.
- account_name: as you all probably already know, it is the EOS account name.
- ram_quota: the amount of RAM I hold, measured in byte.
- net_limit: the total amount of net, useable net, and used net of an account, measured in byte.
- cpu_limit: the total amount of CPU, available CPU, and used CPU of an account, measured in us.
- ram_usage: amount of RAM used of an account, measured in byte.
- total_resources: the EOS of the resource allocated to me.
- self_delegated_bandwidth: the information I delegated to myself.
- 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.
- supply: the number of tokens supplied currently.
- max_supply: the total number of tokens.
- 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!
怎样使用EOS.JS的API的更多相关文章
- 原生JS实战:写了个一边玩游戏,一边记JS的API的游戏
本文是苏福的原创文章,转载请注明出处:苏福CNblog:http://www.cnblogs.com/susufufu/p/5878913.html 本程序[一边玩游戏,一边记JS的API]是本人的个 ...
- [转载]fullPage.js中文api 配置参数~
fullPage.js中文api 配置参数 选项 类型 默认值 说明 verticalCentered 字符串 true 内容是否垂直居中 resize 布尔值 false 字体是否随着窗口缩放而缩放 ...
- AngularJS 授权 + Node.js REST api
作者好屌啊,我不懂的他全都懂. Authentication with AngularJS and a Node.js REST api 几个月前,我开始觉得 AngularJS 好像好牛逼的样子,于 ...
- Node.js RESTful API
什么是REST架构? REST表示代表性状态传输.REST是一种基于Web标准的架构,并使用HTTP协议. 它都是围绕着资源,其中每一个组件是资源和一个资源是由一个共同的接口使用HTTP的标准方法获得 ...
- Practical Node.js (2018版) 第8章:Building Node.js REST API Servers
Building Node.js REST API Servers with Express.js and Hapi Modern-day web developers use an architec ...
- jQuery-全屏滚动插件【fullPage.js】API 使用方法总结
jQuery-全屏滚动插件[fullPage.js]API 使用方法总结 jQuery-全屏滚动插件fullPage.js使用方法总结 作者github及下载地址:https://github.c ...
- Node.js 常用 API
Node.js v6.11.2 Documentation(官方文档) Buffer Prior to the introduction of TypedArray in ECMAScript 20 ...
- 十个书写Node.js REST API的最佳实践(上)
收录待用,修改转载已取得腾讯云授权 原文:10 Best Practices for Writing Node.js REST APIs 我们会通过本文介绍下书写Node.js REST API的最佳 ...
- 十个书写Node.js REST API的最佳实践(下)
收录待用,修改转载已取得腾讯云授权 5. 对你的Node.js REST API进行黑盒测试 测试你的REST API最好的方法之一就是把它们当成黑盒对待. 黑盒测试是一种测试方法,通过这种方法无需知 ...
随机推荐
- 【问题集】redis.clients.jedis.exceptions.JedisDataException: ERR value is not an integer or out of range
redis.clients.jedis.exceptions.JedisDataException: ERR value is not an integer or out of range incrm ...
- MVC的ViewData自动给Razor写的input赋值
问题: 写编辑的时候,突然发现,没有值的model,突然出现了值,而且值是ViewData中值. 后台: this.ViewData["test"] = "测试" ...
- [破解] nasca drm file -ver1.00
在使用nasca系统中的下载相应的文件时,默认下载会被Nasca加密,可以通过下面的方式进行免除加密. 首先我们需要了解没有加密系统的默认下载过程: 当下载文件33333333333.pdf时,由于文 ...
- SQL逻辑查询语句执行顺序 需要重新整理
一.SQL语句定义顺序 1 2 3 4 5 6 7 8 9 10 SELECT DISTINCT <select_list> FROM <left_table> <joi ...
- D - Game Prediction
Suppose there are M people, including you, playing a special card game. At the beginning, each playe ...
- 树剖||树链剖分||线段树||BZOJ4034||Luogu3178||[HAOI2015]树上操作
题面:P3178 [HAOI2015]树上操作 好像其他人都嫌这道题太容易了懒得讲,好吧那我讲. 题解:第一个操作和第二个操作本质上是一样的,所以可以合并.唯一值得讲的点就是:第二个操作要求把某个节点 ...
- RabbitMQ in Depth札记——AMQ协议
RPC传输 作为AMQP的实现,RabbitMQ使用RPC(remote procedure call)模式进行远程会话.而不同于一般的RPC会话--客户端发出指令,服务端响应,但服务端不会向客户端发 ...
- win10 安装 open live write
安装完 open live write后将Memento.OLW_V1.0.0.3.7z解压到C:\Users\pc_name\AppData\Local\OpenLiveWriter\app-0.6 ...
- RabbitMQ下的生产消费者模式与订阅发布模式
所谓模式,就是在某种场景下,一类问题及其解决方案的总结归纳.生产消费者模式与订阅发布模式是使用消息中间件时常用的两种模式,用于功能解耦和分布式系统间的消息通信,以下面两种场景为例: 数据接入 假设 ...
- HTTP缓存机制及原理
前言 Http 缓存机制作为 web 性能优化的重要手段,对于从事 Web 开发的同学们来说,应该是知识体系库中的一个基础环节,同时对于有志成为前端架构师的同学来说是必备的知识技能.但是对于很多前端同 ...