Libra JSON-RPC接口
JSON-RPC接口规范
1. 概述
Libra客户端API基于JSON-RPC协议。该规范定义了客户端API端点和类型,并提供了使用示例。目前官方实现的Java、Go、Python SDK均基于JSON-RPC接口实现。
已发布的稳定的方法列表(除非特别说明,该方法需要所有参数):
- submit(data: string) -> void
- get_transactions(start_version: unsigned_int64, limit: unsigned_int64, include_events: boolean) -> List<Transaction>
- get_account(account: string) -> Account
- get_account_transaction(account: string, sequence_number: unsigned_int64, include_events: boolean) -> List<Transaction>
- get_account_transactions(account: string, start: unsigned_int64, limit: unsigned_int64, include_events: boolean) -> Transaction
- get_metadata(version: unsigned_int64) -> Metadata
- get_events(key: string, start: unsigned_int64, limit: unsigned_int64) -> List<Event>
- get_currencies() -> List<CurrencyInfo>
2. 官方客户端SDK
[Go] (https://github.com/libra/libra-client-sdk-go)
[Java] (https://github.com/libra/libra-client-sdk-java)
[Python] (https://github.com/libra/libra-client-sdk-python)
3. JSON-RPC规范
JSON-RPC是一种无状态、轻量级远程过程调用(RPC)协议。更多细节请参考JSON-RPC规范。
3.1 Libra扩展
JSON-RPC响应对象通过以下字段进行扩展:
字段 | 类型 | 意义 |
---|---|---|
libra_chain_id | unsigned int8 | 网络链id,例如,测试网络链id是2 |
libra_ledger_version | unsigned int64 | 服务端最新的账本版本号 |
libra_ledger_timestampusec | unsigned int64 | 服务端最新的账本时间戳(微秒级) |
可以使用此信息来验证网络中节点的活动/状态:如果时间戳或版本是旧的,这意味着请求命中了一个完整的节点,而不是最新的。
示例:
{
"id": 1,
"jsonrpc": "2.0",
"libra_chain_id": 2,
"libra_ledger_timestampusec": 1596680521771648,
"libra_ledger_version": 3253133,
"result": {
"timestamp": 1596680521771648,
"version": 3253133
}
}
3.2 批处理请求
JSON-RPC协议允许对请求进行批处理。可以将任意数量的请求(默认情况下最多20个)合并成单个批处理并提交给服务器。这些请求将在单个请求上下文中一起处理。
3.3 错误
如果在请求期间发生错误,它们将在error对象中返回,如:https://www.jsonrpc.org/specification#error_object中定义的那样。对于任何无效的请求或参数请求,将返回一个带有人类可读信息的标准错误代码和消息。
代码 | 意义 |
---|---|
-32600 | 标准的非法请求错误 |
-32601 | 方法未找到或者未指定 |
-32602 | 参数无效 |
-32604 | 格式无效 |
除非下面特别提到,Libra JSON-RPC对于一般的服务器端错误将返回默认的错误代码-32000。在“message”和“data”字段中可能会返回更多的信息,但这并不能保证。
3.4 版本
我们使用URI版本控制来版本化我们的API,当前版本是v1。例如,要命中testnet,服务器url是:https://testnet.libra.org/v1。你可以查看api更新日志(https://github.com/libra/libra/blob/master/json-rpc/API-CHANGELOG.md)了解更多关于API的变化。
4. 跨域支持
跨域支持是内嵌。
允许:
- 源(Origin): any
- 请求方法: POST
- 请求头: content-type
5. 接口列表
5.1 submit方法
描述
将已签名的交易提交到一个完整的节点。
参数
名字 | 类型 | 描述 |
---|---|---|
data | string | 已签名的交易数据 - LCS序列化的LibraSignedTransaction类型 |
创建“data”参数的步骤:
-
创建签名消息:
i. "LIBRA::RawTransaction"字符串的SHA3哈希字节
ii. "RawTransaction" LCS序列号字节
iii. 合并以上两个字节
-
使用
Ed25519
和账户私钥签名消息 -
序列化SignedTransaction为字节,然后将十六进制编码字符串作为已签名交易的
data
参数。
更多信息请参考:Crypto Spec
返回值
Null - 成功
注意:
- 虽然提交无效的交易会立即返回错误,但是提交成功并不意味着交易将被成功执行。
- 客户端应该使用发送方帐户地址和RawTransaction的sequence_number调用get_account_transaction ,以确定交易是否被执行。
- 提交交易但尚未执行之后,调用
get_account_transaction
将返回null。 - 如果get_account_transaction返回一个交易,客户端应该验证Transaction#signature == SignedTransaction签名,因为有可能有另一个交易以相同的帐户序列号提交了。
- 在确认交易是提交的SignedTransaction之后,客户端应该通过检查[Transaction#vm_status] == "executed"确认交易已成功执行;任何其他vm_status都意味着执行失败。vm_status可能包含一些信息,以便客户端了解发生了什么错误。
- 在Libra中没有部分执行,因此交易要么完全有效,要么根本没有效果。
- 有可能一个交易在成功提交后不能执行,因此你不能通过get_account_transaction方法找到它。为了避免无休止的等待,客户端应该设置一个合理的交易到期时间戳(RawTransaction#expiration_timestamp_secs),客户端可以继续尝试get_account_transaction,并在响应中使用交易到期时间戳检查libra_ledger_timestampusec。如果传递了到期时间戳,交易将不会被执行,因此客户端可以安全地用新的到期时间戳重新构造交易并再次提交。
错误
交易过程中的错误由不同的错误代码表示:
代码 | 描述 |
---|---|
-32000 | 默认的服务端错误 |
-32001 | 虚拟机验证(validation)错误 |
-32002 | 虚拟机校验(verification)错误 |
-32003 | 虚拟机不变量违背错误 |
-32004 | 虚拟机反序列化错误 |
-32005 | 虚拟机执行错误 |
-32006 | 虚拟机未知错误 |
-32007 | 内存池错误:不合法的序列号 |
-32008 | 内存池已满错误 |
-32009 | 内存池错误:帐户达到每个帐户的最大容量限制 |
-32010 | 内存池错误:无效更新(只gas价格上涨被允许) |
-32011 | 内存池错误:交易没有通过虚拟机验证 |
-32012 | 未知错误 |
示例
// Request: submits a transaction whose hex-encoded LCS byte representation is in params
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"submit","params":["1668F6BE25668C1A17CD8CAF6B8D2F25370000000000000001E101A11CEB0B010000000701000202020403061004160205181D0735610896011000000001010000020001000003020301010004010300010501060C0108000506080005030A020A020005060C05030A020A020109000C4C696272614163636F756E741257697468647261774361706162696C6974791B657874726163745F77697468647261775F6361706162696C697479087061795F66726F6D1B726573746F72655F77697468647261775F6361706162696C69747900000000000000000000000000000001010104010C0B0011000C050E050A010A020B030B0438000B05110202010700000000000000000000000000000001034C4252034C4252000403262E691EC8C7E3E23470D8C3EE26E1A70140420F00000000000400040040420F00000000000000000000000000034C425200E8764817000000020020F549A91FB9989883FB4D38B463308F3EA82074FB39EA74DAE61F62E11BF55D25405CD26F114183C44874DD3F861E0AD24B8E5D8B8C1CAA1B79C7E641C664AE3FD645E4310237A0DC046046DEFBE27C4F15CAAB55A76BBAC15E92B444431232DE0C"],"id": 1}' https://testnet.libra.org/v1
// Response, for successful transaction submission
{
"id":1,
"jsonrpc":"2.0",
"libra_chain_id":2,
"libra_ledger_timestampusec":1596736351198722,
"libra_ledger_version":3475232,
"result":null
}
5.2 get_transactions方法
描述
获取区块链上的交易。
参数
名字 | 类型 | 描述 |
---|---|---|
start_version | unsigned int64 | 从这个查询的交易版本开始 |
limit | unsigned int64 | 限制返回的交易数,最大值为1000 |
include_events | boolean | 如果设置为true,也会为每个交易获取事件(events) |
返回值
交易( Transaction)对象数组
如果include_events为false,交易对象中的events字段将是一个空数组。
示例
// Request: fetches 10 transactions since version 100000
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"get_transactions","params":[100000, 10, false],"id":1}' https://testnet.libra.org/v1
// Response
{
"id": 1,
"jsonrpc": "2.0",
"libra_chain_id": 2,
"libra_ledger_timestampusec": 1596694433936687,
"libra_ledger_version": 3308663,
"result": [
{
"events": [],
"gas_used": 100000000,
"hash": "1dfa3ff87be2aa21e990324a4b70d300621f81bfb48621a74136a23c4a68b7a7",
"transaction": {
"timestamp_usecs": 1596085070813591,
"type": "blockmetadata"
},
"version": 100000,
"vm_status": "executed"
},
{
"events": [],
"gas_used": 100000000,
"hash": "c1e1e8316eae3bbc0f13f8d9616591edd83adfb6fa7c8fcfbc51398e770114ef",
"transaction": {
"timestamp_usecs": 1596085071054623,
"type": "blockmetadata"
},
"version": 100001,
"vm_status": "executed"
},
{
"events": [],
"gas_used": 175,
"hash": "4b31f147fd659ca68fa1382d700901e0b987d2358b421132b7a7bb2ac4542fce",
"transaction": {
"chain_id": 2,
"expiration_timestamp_secs": 1596085170,
"gas_currency": "LBR",
"gas_unit_price": 0,
"max_gas_amount": 1000000,
"public_key": "86f38df4199842f3bfe0dcd003aaf739f9cddd2845b2c5a3318b1878d56b0eb8",
"script": {
"amount": 100000,
"currency": "LBR",
"metadata": "",
"metadata_signature": "",
"receiver": "2ce4a93c05ba7ac8e6e94736731b3ddd",
"type": "peer_to_peer_transaction"
},
"script_hash": "61749d43d8f10940be6944df85ddf13f0f8fb830269c601f481cc5ee3de731c8",
"sender": "c778574753e789661d8223bc1940fae3",
"sequence_number": 16,
"signature": "b66d72e3f20034b03d805c3652062a5921aabd3d01f08f9977f08ae5fc7c77694e852cfbe8e9c53c2bb1d4d268042892bf480481cf330713694777f1226fa208",
"signature_scheme": "Scheme::Ed25519",
"type": "user"
},
"version": 100002,
"vm_status": { "type": "executed" }
},
....
]
}
5.3 get_account方法
描述
获取给定帐户地址的最新帐户信息。
参数
名字 | 类型 | 描述 |
---|---|---|
account | string | 十六进制编码的账户地址 |
返回值
Account - 如果账户存在
Null - 如果账户不存在
示例
// Request: fetches account for account address "1668f6be25668c1a17cd8caf6b8d2f25"
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"get_account","params":["1668f6be25668c1a17cd8caf6b8d2f25"],"id":1}' https://testnet.libra.org/v1
// Response
{
"libra_chain_id" : 2,
"jsonrpc" : "2.0",
"libra_ledger_timestampusec" : 1597084681499780,
"result" : {
"delegated_key_rotation_capability" : false,
"received_events_key" : "00000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"authentication_key" : "d939b0214b484bf4d71d08d0247b755a1668f6be25668c1a17cd8caf6b8d2f25",
"balances" : [
{
"amount" : 2194000000,
"currency" : "LBR"
}
],
"sequence_number" : 11,
"delegated_withdrawal_capability" : false,
"sent_events_key" : "01000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"is_frozen" : false,
"role" : {
"type": parent_vasp",
"num_children" : 0,
"base_url" : "https://libra.org",
"human_name" : "testnet",
"compliance_key" : "b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde",
"expiration_time" : 18446744073709551615
}
},
"id" : 1,
"libra_ledger_version" : 1303433
}
// Sample Response for non-existent account
{
"id": 1,
"jsonrpc": "2.0",
"libra_chain_id": 2,
"libra_ledger_timestampusec": 1596694171246702,
"libra_ledger_version": 3307614,
"result": null
}
5.4 get_account_transaction方法
描述
获取由给定序列号的帐户发送的交易。
参数
名字 | 类型 | 描述 |
---|---|---|
account | string | 十六进制编码的账户地址 |
sequence | unsigned int64 | 账户的序列号 |
include_events | boolean | 如果设置为true,也会为每个交易获取事件(events) |
返回值
Transaction - 如果交易存在
Null - 如果交易不存在
示例
// Request: fetches transaction for account address "1668f6be25668c1a17cd8caf6b8d2f25" and sequence number 0, with including events associated with this transaction
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"get_account_transaction","params":["1668f6be25668c1a17cd8caf6b8d2f25", 0, true],"id":1}' https://testnet.libra.org/v1
// Response
{
"id": 1,
"jsonrpc": "2.0",
"libra_chain_id": 2,
"libra_ledger_timestampusec": 1596694618402871,
"libra_ledger_version": 3309406,
"result": {
"events": [
{
"data": {
"amount": {
"amount": 1000000,
"currency": "LBR"
},
"metadata": "",
"receiver": "262e691ec8c7e3e23470d8c3ee26e1a7",
"sender": "1668f6be25668c1a17cd8caf6b8d2f25",
"type": "sentpayment"
},
"key": "01000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"sequence_number": 0,
"transaction_version": 106548
},
{
"data": {
"amount": {
"amount": 1000000,
"currency": "LBR"
},
"metadata": "",
"receiver": "262e691ec8c7e3e23470d8c3ee26e1a7",
"sender": "1668f6be25668c1a17cd8caf6b8d2f25",
"type": "receivedpayment"
},
"key": "0000000000000000262e691ec8c7e3e23470d8c3ee26e1a7",
"sequence_number": 1,
"transaction_version": 106548
}
],
"gas_used": 175,
"hash": "0fa27a781a9086e80a870851ea4f1b14090fb8b5bd9933e27447ab806443e08e",
"transaction": {
"chain_id": 2,
"expiration_timestamp_secs": 100000000000,
"gas_currency": "LBR",
"gas_unit_price": 0,
"max_gas_amount": 1000000,
"public_key": "f549a91fb9989883fb4d38b463308f3ea82074fb39ea74dae61f62e11bf55d25",
"script": {
"amount": 1000000,
"currency": "LBR",
"metadata": "",
"metadata_signature": "",
"receiver": "262e691ec8c7e3e23470d8c3ee26e1a7",
"type": "peer_to_peer_transaction"
},
"script_hash": "61749d43d8f10940be6944df85ddf13f0f8fb830269c601f481cc5ee3de731c8",
"sender": "1668f6be25668c1a17cd8caf6b8d2f25",
"sequence_number": 0,
"signature": "a181a036ba68fcd25a7ba9f3895caf720af7aee4bf86c4d798050a1101e75f71ccd891158c8fa0bf349bbb66fb0ba50b29b6fb29822dc04071aff831735e6402",
"signature_scheme": "Scheme::Ed25519",
"type": "user"
},
"version": 106548,
"vm_status": { "type": "executed" }
}
}
5.5 get_account_transactions方法
描述
获取该帐户发送的所有交易。
参数
名字 | 类型 | 描述 |
---|---|---|
account | string | 十六进制编码的账户地址 |
start | unsigned int64 | 查询开始的账户序列号 |
limit | unsigned int64 | 返回的最大的交易数 |
include_events | boolean | 如果设置为true,也会为每个交易获取事件(events) |
返回值
交易对象数组
如果include_events为false,交易对象中的events字段将是一个空数组。
示例
// Request: fetches transaction for account address "0xc1fda0ec67c1b87bfb9e883e2080e530", starting sequence number 0, limit 100, without including events associated with this transaction
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"get_account_transactions","params":["c1fda0ec67c1b87bfb9e883e2080e530", 0, 100, false],"id":1}'
// Response
{
"id":1,
"jsonrpc":"2.0",
"result": [{
"events":[],
"gas_used":0,
"transaction":{
"expiration_timestamp_secs":1590680747,
"gas_unit_price":0,
"max_gas_amount":1000000,
"public_key":"500a9002995e1af93bbdaf977385ed507b174bb3dc6936efd72612d56198a19d",
"script":{
"amount":10000000,
"auth_key_prefix":"6484f428e88bba93de5053e051acb6ec",
"metadata":"",
"metadata_signature":"",
"receiver":"4ac94d88e90acd4cf0294e898e421e94",
"type":"peer_to_peer_transaction"
},
"script_hash":"c8bc3dda60e9662965b3223c22e3d3e3e7b6f698cf1a6930a449eb99daa35e7c",
"sender":"c1fda0ec67c1b87bfb9e883e2080e530",
"sequence_number":0,
"signature":"fe335285e5d87db25f86041d033414bfdf77ddae6f0dfbdc65ff4f5965ff810ef9c85ce00ede0820ce0cf5903f9ab3e93fa6e49bbf770aba9b083a985361fa01",
"signature_scheme":"Scheme::Ed25519",
"type":"user"
},
"version":4433485,
"vm_status": { "type": "executed" }
}]
}
5.6 get_metadata方法
描述
获取区块链/账本的元数据。
参数
名字 | 类型 | 描述 |
---|---|---|
version | unsigned int64 | 交易版本,这个参数是可选的,默认是服务端最新的交易版本号 |
返回值
元数据(Metadata)
注意:字段script_hash_allow_list
, module_publishing_allowed
和libra_version
只在没有提供版本参数时返回(注意,在最新的测试中,这几个字段没有参数时也会返回)。
示例
{
"libra_chain_id": 2,
"libra_ledger_version": 13119449,
"libra_ledger_timestampusec": 1605522793895276,
"jsonrpc": "2.0",
"id": 1,
"result": {
"accumulator_root_hash": "3047573383a853d719dc056c56496ce3fd95a947f7267f7c0a9e07b7b62083a6",
"chain_id": 2,
"libra_version": 1,
"module_publishing_allowed": false,
"script_hash_allow_list": [
"6d9d309c5cc6df4c7082817eb657904781b06b2071552ae762806fce3b623463",
"570b8627a80ded5704775fc18060d58af396bb72565952fb0920221cc21ea9d1",
"19ea57b5051d34306353cc335baedbc022d28055cd6d76238a107ba433295930",
"a801d467df10ac00de027bc427637db66e8afc84a4bb94761b526016cb20a5ef",
"8f019b20740269011c05d8348cc7501bed64c7d56b8726eb8f4e21a01bd2eb4c",
"18da4e8c53fed321d58770e6c3f455848935cdc26153c3b41c166995787cff1d",
"5de6edd4b881622c4f7bc3bb9f2a1f98eeb8ca8483ad4e8dda3691c6bc5cbf32",
"bef38e6ed5ad51f0d060a4e194e4c8379cc6dfb60492c671a885f6752733866b",
"04ec5aec7f5cf5ea55e29cd65542134a7f4bb3c18421fecf00e5102dfe2d7efb",
"afabc7c4a2fd7b54734881f7e760e7d798cd93411839c20860a57e02eebd3893",
"ae693591b0d7169f4a68da27859fc055053b317c81836d6ef66a1418b1e9db5b",
"1a2c5cd660de7217f513bdfaa9c36bef8f384d018f128e7ddbb37dbb21f9b38f",
"387dce4a1f3421a369de8a48c070e7aa8e1e587ecadcf35fe254d3d8df0382b8",
"ff9e545db9c3546d892de6c6716d0a45929a721a14d478da3d689900eb16a394",
"61749d43d8f10940be6944df85ddf13f0f8fb830269c601f481cc5ee3de731c8",
"d01cd5656905ab073fefc899eb4af0c158ad3775d17f5d9731e5b5b040d52cfd",
"dfcfe1d8eb8e7a9dc1038b5d9d015c09c9e38ec6af310de7d5592de359092486",
"2b124c549e828df9bc38c6d45779d155f973116f077d8f0faa92c4d25389a4c1",
"c46e0e6d7579033024c73242b9a031d0d602f46222a79d1c86afcc07a1bbe59d",
"6aa259be3a3f160a5d0d089fdf14d70a3579d23b34bad2ae1dee50f52275ed9c",
"4820a09dae6cbfc9a77a060a919ad5913f91e6d52a75430c0672b44f241b70cc",
"8a1a527d4bf4b4993d525f1c1458235b47c26582762c6ac59cbc3162a0555499",
"157f747315d3cbf7695f6892b1aee3fb493d7fa231dd545fe5f173920b30e657",
"b4e23670c081e09e5da9f3c26aa31f84da8beab55ab299cfdddf64769551ed76",
"6adcf90ce474223545e2c204c1b48fab4ce28693a1d9bf51fb0f06d687d22a3f",
"ccf81752586ce59142e3625dd4aa7463f1e7167812f7de0ac82a924a0638284b",
"b33b71a6e98a50d8f41f00af92feec4fd77ede12d3ceb5052e53c6291920620d",
"7b7d7e02addc3dc14210d1db2baf17779b443b6dc9b70daf88cf4673d458f429",
"27d5e5756fd287f2c3e90bba57cfc82674b7d9890d9e65e4619b81fe6aa1d6c8",
"0e9dceaf3a66b076acb0ddd29041ddea4316716da26c88fdd55dad5fd862a3e3",
"b3a8003b1ebeafab289e75f8adec0f4fe80f7f220c01143173b0caf3b467fa6a",
"8e756eee24336712dcd5d03e20f2b97db7b1f74e26f077d41ba02175874dfd84",
"431c979535f701b76bfb0c4b51f35d4893dd30d4dd52bdf2f31c7002c0067369",
"ffbf8a2b64b711e61376c525a96b4206c791fc050e09a56c12d1ec187ad598ad"
],
"timestamp": 1605522793895276,
"version": 13119449
}
}
5.7 get_events方法
描述
获取给定事件流的事件。
参数
名字 | 类型 | 描述 |
---|---|---|
key | string | 一个事件流全局唯一的标识符 |
start | unsigned int64 | 事件开始的序列号 |
limit | unsigned int64 | 获取事件的最大数量 |
注意:
- 对于
sentpayment
和receivedpayment
事件,调用get_account
来获取给定用户帐户的事件流的事件键。 - 对于与货币相关的事件,调用
get_currencies
获取事件键(例如:与LBR兑换汇率改变的事件键)。
返回值
返回事件对象(Event)的数组。
示例
//Request: get events associated with receivedpayment event stream key "00000000000000001668f6be25668c1a17cd8caf6b8d2f25" for account "1668f6be25668c1a17cd8caf6b8d2f25"
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"get_events","params": ["00000000000000001668f6be25668c1a17cd8caf6b8d2f25", 0, 10], "id":1}' https://testnet.libra.org/v1
//Response
{
"id": 1,
"jsonrpc": "2.0",
"libra_chain_id": 2,
"libra_ledger_timestampusec": 1596694876315159,
"libra_ledger_version": 3310435,
"result": [
{
"data": {
"amount": {
"amount": 100000000,
"currency": "LBR"
},
"metadata": "",
"receiver": "1668f6be25668c1a17cd8caf6b8d2f25",
"sender": "000000000000000000000000000000dd",
"type": "receivedpayment"
},
"key": "00000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"sequence_number": 0,
"transaction_version": 106495
},
{
"data": {
"amount": {
"amount": 100000000,
"currency": "LBR"
},
"metadata": "",
"receiver": "1668f6be25668c1a17cd8caf6b8d2f25",
"sender": "000000000000000000000000000000dd",
"type": "receivedpayment"
},
"key": "00000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"sequence_number": 1,
"transaction_version": 106564
},
{
"data": {
"amount": {
"amount": 100000000,
"currency": "LBR"
},
"metadata": "",
"receiver": "1668f6be25668c1a17cd8caf6b8d2f25",
"sender": "000000000000000000000000000000dd",
"type": "receivedpayment"
},
"key": "00000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"sequence_number": 2,
"transaction_version": 106608
},
{
"data": {
"amount": {
"amount": 100000000,
"currency": "LBR"
},
"metadata": "",
"receiver": "1668f6be25668c1a17cd8caf6b8d2f25",
"sender": "000000000000000000000000000000dd",
"type": "receivedpayment"
},
"key": "00000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"sequence_number": 3,
"transaction_version": 107186
},
{
"data": {
"amount": {
"amount": 100000000,
"currency": "LBR"
},
"metadata": "",
"receiver": "1668f6be25668c1a17cd8caf6b8d2f25",
"sender": "000000000000000000000000000000dd",
"type": "receivedpayment"
},
"key": "00000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"sequence_number": 4,
"transaction_version": 107271
},
{
"data": {
"amount": {
"amount": 100000000,
"currency": "LBR"
},
"metadata": "",
"receiver": "1668f6be25668c1a17cd8caf6b8d2f25",
"sender": "000000000000000000000000000000dd",
"type": "receivedpayment"
},
"key": "00000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"sequence_number": 5,
"transaction_version": 107333
},
{
"data": {
"amount": {
"amount": 100000000,
"currency": "LBR"
},
"metadata": "",
"receiver": "1668f6be25668c1a17cd8caf6b8d2f25",
"sender": "000000000000000000000000000000dd",
"type": "receivedpayment"
},
"key": "00000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"sequence_number": 6,
"transaction_version": 783134
},
{
"data": {
"amount": {
"amount": 100000000,
"currency": "LBR"
},
"metadata": "",
"receiver": "1668f6be25668c1a17cd8caf6b8d2f25",
"sender": "000000000000000000000000000000dd",
"type": "receivedpayment"
},
"key": "00000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"sequence_number": 7,
"transaction_version": 783282
},
{
"data": {
"amount": {
"amount": 100000000,
"currency": "LBR"
},
"metadata": "",
"receiver": "1668f6be25668c1a17cd8caf6b8d2f25",
"sender": "000000000000000000000000000000dd",
"type": "receivedpayment"
},
"key": "00000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"sequence_number": 8,
"transaction_version": 783378
},
{
"data": {
"amount": {
"amount": 100000000,
"currency": "LBR"
},
"metadata": "",
"receiver": "1668f6be25668c1a17cd8caf6b8d2f25",
"sender": "000000000000000000000000000000dd",
"type": "receivedpayment"
},
"key": "00000000000000001668f6be25668c1a17cd8caf6b8d2f25",
"sequence_number": 9,
"transaction_version": 2371067
}
]
}
5.8 get_currencies方法
描述
获得Libra区块链支持的各种货币的信息。
参数
无
返回值
返回CurrencyInfo对象的数组。
示例
// Request: fetches currencies supported by the system
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"get_currencies","params":[],"id":1}' https://testnet.libra.org/v1
// Response
{
"id": 1,
"jsonrpc": "2.0",
"libra_chain_id": 2,
"libra_ledger_timestampusec": 1596680410015647,
"libra_ledger_version": 3252698,
"result": [
{
"burn_events_key": "02000000000000000000000000000000000000000a550c18",
"cancel_burn_events_key": "04000000000000000000000000000000000000000a550c18",
"code": "Coin1",
"exchange_rate_update_events_key": "05000000000000000000000000000000000000000a550c18",
"fractional_part": 100,
"mint_events_key": "01000000000000000000000000000000000000000a550c18",
"preburn_events_key": "03000000000000000000000000000000000000000a550c18",
"scaling_factor": 1000000,
"to_lbr_exchange_rate": 0.5
},
{
"burn_events_key": "0c000000000000000000000000000000000000000a550c18",
"cancel_burn_events_key": "0e000000000000000000000000000000000000000a550c18",
"code": "LBR",
"exchange_rate_update_events_key": "0f000000000000000000000000000000000000000a550c18",
"fractional_part": 1000,
"mint_events_key": "0b000000000000000000000000000000000000000a550c18",
"preburn_events_key": "0d000000000000000000000000000000000000000a550c18",
"scaling_factor": 1000000,
"to_lbr_exchange_rate": 1
}
]
}