create account

学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS by oflyhigh

View this thread on: hive.blogpeakd.comecency.com
· @oflyhigh ·
$79.19
学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS
先庆祝一下,昨天我终于跑步上车了,然后——***翻车了***😭

有没有被我忽悠一起上车的朋友啊,千万不要感谢我(谁丢的西红柿?谁丢的臭鸡蛋?不许再丢了)

不过是谁说的来着,不能计较一城一池的得失。如果BTS过段时间涨到5元10元,再回头看这一两毛钱的涨跌,不过是毛毛细雨。
***(注:我给自己打气呢,不构成投资建议啊)***

好了言归正传,既然已经上车了,就安心好好玩,记录并汇报一下这两天的对BTS RPC的学习。

![](https://steemitimages.com/DQmbetK9MHQbWok8gPBTMkvuJQe6meQP5rRKdXQbwgvCUc5/image.png)

----

# BTS RPC

#### 工作流程
![](https://steemitimages.com/DQmcdz5ZUg6s5c6WX6jBYbMsq8pSK7L7MwcBBdAYjfUhS6c/image.png)
(来自:http://docs.bitshares.org/api/index.html)

#### 文档地址

http://docs.bitshares.org/api/rpc.html

#### 调用格式
```
{
 "jsonrpc": "2.0",
 "id": 1
 "method": "get_accounts",
 "params": [["1.2.0", "1.2.1"]],
}
```
如果你有接触过STEEM的RPC调用,就会发现二者非常相似。

# 调用示例
`curl --data '{"jsonrpc": "2.0", "method": "get_accounts", "params": [["1.2.0", "1.2.1"]], "id": 1}' http://127.0.0.1:8090/rpc`

因为我没在本地装节点(确切地说是我不会弄啊),所以我直接使用了公共节点:
`curl --data '{"jsonrpc": "2.0", "method": "get_accounts", "params": [["1.2.0", "1.2.1"]], "id": 1}' https://openledger.hk/ws`

返回了如下数据(部分):
![](https://steemitimages.com/DQmYGpNjJ36Mzons6H8jHxyA4QZruqr22hJDkvbrnvrHtig/image.png)
(好吧,其实没法看,之后在详细分析)

好吧,尽管一知半解,但是总算明白一点点了。

# Database API

上述调用中的***`method`***和***`params`***都是在API中被定义,比如说***`Database API`***。

#### 文档地址
http://docs.bitshares.org/api/database.html

#### API示例
以之前我们通过***`curl`***发起的get_accounts调用为例,在***`Database API`***中定义如下:
![](https://steemitimages.com/DQmcktgDQ5qQD7dFekMnnyy7g2tnRwM5iknem195GKxLkK7/image.png)


# 实际的例子

有了上述关于***`BTS RPC`***以及***`Database API`***介绍,我们就可以拿来做一些实际的工作了,比如查查我的账户下有多少资产余额?

原本以为,像STEEM一样,读取账户信息就会读到资产余额信息,但是BTS与STEEM还有有些不同。

用***`get_account_by_name`***读出来的并不包含资产余额信息
`curl -s --data '{"jsonrpc": "2.0", "method": "get_account_by_name", "params": ["oflyhigh"], "id": 1}' https://openledger.hk/ws`
![](https://steemitimages.com/DQmbYz83kqPFsDzciNHcaFW23ZxHWi1GAGR8NXsuooABD7R/image.png)
(注:***`get_full_accounts`***返回的内容包含余额信息)

所以我们要用***`get_named_account_balances`***来读取资产
`curl -s --data '{"jsonrpc": "2.0", "method": "get_named_account_balances", "params": ["oflyhigh", []], "id": 1}' https://openledger.hk/ws`
![](https://steemitimages.com/DQmTvyzpDe2eL2jBSUjkw7mohZgwos1LUw8ydp2LLmRP56k/image.png)
哇,我有点激动,这是啥东西,我怎么有这么多,我已经数不清楚有多少位了。

不过貌似激动的有点早,让我来看看这是啥资产,调用***`get_objects`***
`curl -s --data '{"jsonrpc": "2.0", "method": "get_objects", "params": [["1.3.0"]], "id": 1}' https://openledger.hk/ws`
![](https://steemitimages.com/DQmTxybZqbWiz3XUxWTZjAzeWC3FvuaLS1984CuCwCBo4Ep/image.png)
原来就是BTS,精度是五位,也就是我其实并没有几个😭
(从易读性来将,应该调用***`get_assets`***,其实本质都一样啦)

# 总结

通过上边的学习和示例,大致了解了BTS RPC调用的机制。还有很多东西要去学习和了解,就不多介绍啦。

既然币价还没飞起来,就好好学习吧。 币价迟早会飞起来的,我的预测一贯很准的😭。


# 参考文档
* http://docs.bitshares.org/bitshares/index.html
* http://docs.bitshares.org/api/index.html
* http://docs.bitshares.org/api/rpc.html
* http://docs.bitshares.org/api/database.html
* http://docs.bitshares.org/development/blockchain/objects.html
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 211 others
properties (23)
authoroflyhigh
permlinkbts-learn-the-remote-procedure-call-of-bts
categorybitshares
json_metadata{"tags":["bitshares","bts","api","rpc","cn"],"image":["https://steemitimages.com/DQmbetK9MHQbWok8gPBTMkvuJQe6meQP5rRKdXQbwgvCUc5/image.png","https://steemitimages.com/DQmcdz5ZUg6s5c6WX6jBYbMsq8pSK7L7MwcBBdAYjfUhS6c/image.png","https://steemitimages.com/DQmYGpNjJ36Mzons6H8jHxyA4QZruqr22hJDkvbrnvrHtig/image.png","https://steemitimages.com/DQmcktgDQ5qQD7dFekMnnyy7g2tnRwM5iknem195GKxLkK7/image.png","https://steemitimages.com/DQmbYz83kqPFsDzciNHcaFW23ZxHWi1GAGR8NXsuooABD7R/image.png","https://steemitimages.com/DQmTvyzpDe2eL2jBSUjkw7mohZgwos1LUw8ydp2LLmRP56k/image.png","https://steemitimages.com/DQmTxybZqbWiz3XUxWTZjAzeWC3FvuaLS1984CuCwCBo4Ep/image.png"],"links":["http://docs.bitshares.org/api/index.html","http://docs.bitshares.org/api/rpc.html","http://docs.bitshares.org/api/database.html","http://docs.bitshares.org/bitshares/index.html","http://docs.bitshares.org/development/blockchain/objects.html"],"app":"steemit/0.1","format":"markdown"}
created2017-11-02 10:58:00
last_update2017-11-02 10:58:00
depth0
children22
last_payout2017-11-09 10:58:00
cashout_time1969-12-31 23:59:59
total_payout_value66.269 HBD
curator_payout_value12.925 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,846
author_reputation6,315,849,788,242,814
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,251,124
net_rshares38,376,764,574,216
author_curate_reward""
vote details (275)
@brysj22952 ·
真搞不懂为啥BTS价格老是上不去。
properties (22)
authorbrysj22952
permlinkre-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t110754641z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-02 11:08:00
last_update2017-11-02 11:08:00
depth1
children3
last_payout2017-11-09 11:08:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length17
author_reputation203,024,116,259
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,251,767
net_rshares0
@imyao ·
因为筹码太分散了……
properties (22)
authorimyao
permlinkre-brysj22952-re-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t164515532z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-02 16:45:15
last_update2017-11-02 16:45:15
depth2
children1
last_payout2017-11-09 16:45:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length10
author_reputation2,782,342,637,822
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,278,356
net_rshares0
@chenlocus ·
我觉得主要是交易量还是少了。它应该接受更多的代币。还有就是无法直接和法币兑换。
properties (22)
authorchenlocus
permlinkre-imyao-re-brysj22952-re-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171103t030333457z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-03 03:03:33
last_update2017-11-03 03:03:33
depth3
children0
last_payout2017-11-10 03:03:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length39
author_reputation127,654,349,067,342
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,315,294
net_rshares0
@oflyhigh ·
比特币也有过低谷:)
properties (22)
authoroflyhigh
permlinkre-brysj22952-re-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t111207058z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-02 11:12:09
last_update2017-11-02 11:12:09
depth2
children0
last_payout2017-11-09 11:12:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length10
author_reputation6,315,849,788,242,814
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,252,017
net_rshares0
@chenlocus ·
$0.29
BTS, STEEM, EOS都是偶看好的东西,区块链代币里确定性最强的几个。BTS翻车,没关系,有很多像偶一样的人会团结起来把车扶好。
👍  
properties (23)
authorchenlocus
permlinkre-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t234913804z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-02 23:49:12
last_update2017-11-02 23:49:12
depth1
children1
last_payout2017-11-09 23:49:12
cashout_time1969-12-31 23:59:59
total_payout_value0.214 HBD
curator_payout_value0.071 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length68
author_reputation127,654,349,067,342
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,305,515
net_rshares139,563,881,531
author_curate_reward""
vote details (1)
@oflyhigh ·
哈哈,快扶好,我们继续开车! 😀
👍  
properties (23)
authoroflyhigh
permlinkre-chenlocus-re-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171103t011224153z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-03 01:12:24
last_update2017-11-03 01:12:24
depth2
children0
last_payout2017-11-10 01:12:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length16
author_reputation6,315,849,788,242,814
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,309,448
net_rshares3,233,163,863
author_curate_reward""
vote details (1)
@cnbuddy ·
今天你那天气如何?cn区点赞机器人 @cnbuddy 谢谢你对cn区的贡献。 @cnbuddy 的梦想是能够对cn区快速发展作出自己的贡献。我的主页会定期总结cn区活动动态,欢迎围观。如果不想再收到我的留言,请回复“取消”。
properties (22)
authorcnbuddy
permlinkre-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t112823698z
categorybitshares
json_metadata""
created2017-11-02 11:28:24
last_update2017-11-02 11:28:24
depth1
children9
last_payout2017-11-09 11:28:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length112
author_reputation-1,449,160,991,441
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,252,948
net_rshares0
@cifer ·
取消
properties (22)
authorcifer
permlinkre-cnbuddy-re-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t143351718z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-02 14:33:51
last_update2017-11-02 14:33:51
depth2
children0
last_payout2017-11-09 14:33:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2
author_reputation8,256,283,569,876
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,266,969
net_rshares0
@oflyhigh ·
取消
👍  
properties (23)
authoroflyhigh
permlinkre-cnbuddy-re-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t113230956z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-02 11:32:33
last_update2017-11-02 11:32:33
depth2
children7
last_payout2017-11-09 11:32:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2
author_reputation6,315,849,788,242,814
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,253,188
net_rshares1,088,735,217
author_curate_reward""
vote details (1)
@deanliu ·
恢復
properties (22)
authordeanliu
permlinkre-oflyhigh-re-cnbuddy-re-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t114509233z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-02 11:45:12
last_update2017-11-02 11:45:12
depth3
children6
last_payout2017-11-09 11:45:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2
author_reputation3,091,849,888,189,995
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,254,001
net_rshares0
@freshstuff ·
Thanks for showing this
properties (22)
authorfreshstuff
permlinkre-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t105920050z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-02 10:59:21
last_update2017-11-02 10:59:21
depth1
children0
last_payout2017-11-09 10:59:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length23
author_reputation4,090,858,283,419
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,251,220
net_rshares0
@goldkey ·
thanks for all the great code and explanation.
properties (22)
authorgoldkey
permlinkre-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t113349352z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-02 11:33:48
last_update2017-11-02 11:33:48
depth1
children0
last_payout2017-11-09 11:33:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length46
author_reputation357,343,665,891,557
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,253,262
net_rshares0
@jubi ·
已上车…😄 等等
properties (22)
authorjubi
permlinkre-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t110808080z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-02 11:08:18
last_update2017-11-02 11:08:18
depth1
children3
last_payout2017-11-09 11:08:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length8
author_reputation82,406,494,254,467
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,251,779
net_rshares0
@oflyhigh ·
我的体量太大,车被我压坏了 😭
properties (22)
authoroflyhigh
permlinkre-jubi-re-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t111228538z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-02 11:12:30
last_update2017-11-02 11:12:30
depth2
children2
last_payout2017-11-09 11:12:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length15
author_reputation6,315,849,788,242,814
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,252,031
net_rshares0
@jubi ·
那还怎么发车…下车下车
properties (22)
authorjubi
permlinkre-oflyhigh-re-jubi-re-oflyhigh-bts-learn-the-remote-procedure-call-of-bts-20171102t114315313z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2017-11-02 11:43:24
last_update2017-11-02 11:43:24
depth3
children1
last_payout2017-11-09 11:43:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length11
author_reputation82,406,494,254,467
root_title"学习一下BTS的远程过程调用 / Learn the remote procedure call of BTS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id19,253,887
net_rshares0