Skip to content

Commit e445926

Browse files
author
Eunsoo Park
committed
Update README.md. Add APIs for BTP
1 parent ea9d7bb commit e445926

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,21 @@ tx = icon_service.get_transaction("0x000...000")
102102
# Returns the result of a transaction by transaction hash
103103
tx_result = icon_service.get_transaction_result("0x000...000")
104104

105+
# Returns the data based on the hash
106+
tx_result = icon_service.get_data_by_hash("0x000...000")
107+
108+
# Returns block header for specified height.
109+
tx_result = icon_service.get_block_header_by_height(1000)
110+
111+
# Returns votes for the block specified by height
112+
tx_result = icon_service.get_votes_by_height(1000)
113+
114+
# Returns proof for the receipt. Proof, itself, may include the receipt.
115+
tx_result = icon_service.get_proof_for_result("0x000...000", 0)
116+
117+
# Returns proof for the receipt and the events in it. The proof may include the data itself.
118+
tx_result = icon_service.get_proof_for_events("0x000...000", 0, [ "0x0", "0x2" ])
119+
105120
# Generates a call instance using the CallBuilder
106121
call = CallBuilder().from_(wallet.get_address())\
107122
.to("cx000...1")\
@@ -375,6 +390,96 @@ tx_result = icon_service.get_transaction_result("0x000...000")
375390
```
376391

377392

393+
### get_data_by_hash
394+
395+
```python
396+
get_data_by_hash(hash: str)
397+
```
398+
399+
Get data by hash.
400+
401+
It can be used to retrieve data based on the hash algorithm (SHA3-256).
402+
403+
Following data can be retrieved by a hash.
404+
405+
* BlockHeader with the hash of the block
406+
* Validators with BlockHeader.NextValidatorsHash
407+
* Votes with BlockHeader.VotesHash
408+
* etc…
409+
410+
Delegates to **icx_getDataByHash** RPC method
411+
412+
#### Parameters
413+
414+
hash : The hash value of the data to retrieve.
415+
416+
#### Returns
417+
418+
#### Error Cases
419+
420+
* DataTypeException : Data type is invalid.
421+
* JSONRPCException : JSON-RPC Response is error.
422+
423+
#### Example
424+
425+
```python
426+
tx_result = icon_service.get_data_by_hash("0x000...000")
427+
```
428+
429+
### get_block_header_by_height
430+
431+
```python
432+
get_block_header_by_height(height: int)
433+
```
434+
Get block header for specified height.
435+
436+
Delegates to **icx_getBlockHeaderByHeight** RPC method
437+
438+
#### Parameters
439+
440+
height : The height of the block
441+
442+
#### Returns
443+
444+
#### Error Cases
445+
446+
* DataTypeException : Data type is invalid.
447+
* JSONRPCException : JSON-RPC Response is error.
448+
449+
#### Example
450+
451+
```python
452+
tx_result = icon_service.get_block_header_by_height(1000)
453+
```
454+
455+
### get_votes_by_height
456+
457+
```python
458+
get_votes_by_height(height: int)
459+
```
460+
Get votes for the block specified by height.
461+
462+
Normally votes for the block are included in the next. So, even though the block is finalized by votes already, the block including votes may not exist. For that reason, we support this API to get votes as proof for the block.
463+
464+
Delegates to **icx_getVoteByHeight** RPC method
465+
466+
#### Parameters
467+
468+
height : The height of the block
469+
470+
#### Returns
471+
472+
#### Error Cases
473+
474+
* DataTypeException : Data type is invalid.
475+
* JSONRPCException : JSON-RPC Response is error.
476+
477+
#### Example
478+
479+
```python
480+
tx_result = icon_service.get_vote_by_height(1000)
481+
```
482+
378483

379484
### call
380485

0 commit comments

Comments
 (0)