forked from diem/diem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[json-rpc] update json-rpc-spec.md, split it into multiple md files
Closes: diem#5483
- Loading branch information
1 parent
cdab48c
commit f6c1d19
Showing
15 changed files
with
1,197 additions
and
1,876 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
## Method get_account | ||
|
||
**Description** | ||
|
||
Get the latest account information for a given account address. | ||
|
||
|
||
### Parameters | ||
|
||
| Name | Type | Description | | ||
|---------|--------|-----------------------------| | ||
| account | string | Hex-encoded account address | | ||
|
||
|
||
### Returns | ||
|
||
[Account](type_account.md) - If account exists | ||
|
||
Null - If account does not exist | ||
|
||
|
||
### Example | ||
|
||
``` | ||
// 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://client.testnet.libra.org/v1 | ||
// Response | ||
{ | ||
"id": 1, | ||
"jsonrpc": "2.0", | ||
"libra_chain_id": 2, | ||
"libra_ledger_timestampusec": 1596694123535425, | ||
"libra_ledger_version": 3307422, | ||
"result": { | ||
"authentication_key": "d939b0214b484bf4d71d08d0247b755a1668f6be25668c1a17cd8caf6b8d2f25", | ||
"balances": [ | ||
{ | ||
"amount": 12070000000, | ||
"currency": "LBR" | ||
} | ||
], | ||
"delegated_key_rotation_capability": false, | ||
"delegated_withdrawal_capability": false, | ||
"is_frozen": false, | ||
"received_events_key": "00000000000000001668f6be25668c1a17cd8caf6b8d2f25", | ||
"role": { | ||
"parent_vasp": { | ||
"base_url": "https://libra.org", | ||
"compliance_key": "b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde", | ||
"expiration_time": 18446744073709552000, | ||
"human_name": "testnet", | ||
"num_children": 0 | ||
} | ||
}, | ||
"sent_events_key": "01000000000000001668f6be25668c1a17cd8caf6b8d2f25", | ||
"sequence_number": 50 | ||
} | ||
} | ||
// 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 | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
## Method get_account_transaction | ||
|
||
**Description** | ||
|
||
Get the transaction sent by the account with the given sequence number | ||
|
||
|
||
### Parameters | ||
|
||
| Name | Type | Description | | ||
|----------------|----------------|---------------------------------------------------------------| | ||
| account | string | Hex-encoded account address | | ||
| sequence | unsigned int64 | The account sequence number | | ||
| include_events | boolean | Set to true to also fetch events generated by the transaction | | ||
|
||
### Returns | ||
|
||
[Transaction](type_transaction.md) - If transaction exists | ||
|
||
Null - If transaction does not exist | ||
|
||
|
||
### Example | ||
|
||
|
||
``` | ||
// 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://client.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": "executed" | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
## Method get_account_transactions | ||
|
||
**Description** | ||
|
||
Get all transactions sent by the account. | ||
|
||
|
||
### Parameters | ||
|
||
| Name | Type | Description | | ||
|----------------|----------------|---------------------------------------------------------------| | ||
| account | string | Hex-encoded account address | | ||
| start | unsigned int64 | The start of account sequence number | | ||
| limit | unsigned int64 | The maximum number of transactions to return. | | ||
| include_events | boolean | Set to true to also fetch events generated by the transaction | | ||
|
||
|
||
### Returns | ||
|
||
Array of [Transaction](type_transaction.md) objects | ||
|
||
if include_events is false, the events field in the Transaction object will be an empty array. | ||
|
||
|
||
### Example | ||
|
||
|
||
``` | ||
// 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": "executed" | ||
}] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
## Method get_currencies | ||
|
||
**Description** | ||
|
||
Get information about various currencies supported by the Libra blockchain | ||
|
||
|
||
### Parameters | ||
|
||
None | ||
|
||
|
||
### Returns | ||
|
||
Returns array of [CurrencyInfo](type_currency_info.md) objects. | ||
|
||
### Example | ||
|
||
|
||
``` | ||
// 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://client.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": "07000000000000000000000000000000000000000a550c18", | ||
"cancel_burn_events_key": "09000000000000000000000000000000000000000a550c18", | ||
"code": "Coin2", | ||
"exchange_rate_update_events_key": "0a000000000000000000000000000000000000000a550c18", | ||
"fractional_part": 100, | ||
"mint_events_key": "06000000000000000000000000000000000000000a550c18", | ||
"preburn_events_key": "08000000000000000000000000000000000000000a550c18", | ||
"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 | ||
} | ||
] | ||
} | ||
``` |
Oops, something went wrong.