Skip to content

Commit ea22378

Browse files
authored
Update rpc doc (#462)
1 parent 552247b commit ea22378

File tree

6 files changed

+126
-34
lines changed

6 files changed

+126
-34
lines changed

docs/bnb-smart-chain/developers/json-rpc-api.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

docs/bnb-smart-chain/developers/json_rpc_apis/finality-api.md renamed to docs/bnb-smart-chain/developers/json_rpc/bsc-api-list.md

Lines changed: 95 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
---
2-
title: Finality API - BSC Develop
2+
title: Bsc API List- BSC Develop
33
---
44

5+
## Finality API
56
Finality is a crucial aspect of blockchain security, ensuring that once a block is confirmed, it cannot be reversed or altered. This provides users with the confidence to act on the information in the block without delay.
67

7-
## Probabilistic Finality and Economic Finality
8+
### Probabilistic Finality and Economic Finality
89

910
In probabilistic finality, the deeper a block is buried in the chain, the lower the likelihood of it being reverted. The more blocks follow a particular block, the more likely the chain containing that block will be the longest. **Typically, BSC users should wait for at least 11 or 15 different validators to seal a block. If validators are allowed to produce multiple consecutive blocks, the number of blocks required to achieve probabilistic finality is approximately 11\*n or 15\*n, where "n" is the number of consecutive blocks produced.**
1011

1112
Economic Finality refers to the high cost associated with reverting a block. In proof-of-stake systems that use a slashing mechanism (such as Casper FFG, Tendermint, or BSC Fast Finality), if validators violate the voting rules, part or all of their stake can be forfeited. This economic penalty makes it extremely expensive to undermine finality. Generally, block n achieves economic finality by block n+2, meaning that BSC Fast Finality reduces the confirmation time to two blocks in most cases. This improves the user experience by making transaction confirmation faster and more reliable.
1213

13-
## Economic Finality API
14+
### Economic Finality API
1415

1516
### [eth_getHeaderByNumber](<https://www.quicknode.com/docs/kaia/eth_getHeaderByNumber>) as in the Ethereum client.
1617
**Parameters**
1718

18-
QUANTITY|TAG
19+
**BlockNumber** QUANTITY|TAG
1920

2021
* HEX String - an integer block number
2122
* String "earliest" for the earliest/genesis block
@@ -26,15 +27,15 @@ QUANTITY|TAG
2627
### [eth_getBlockByNumber](<https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber>) as in the Ethereum client.
2728
**Parameters**
2829

29-
QUANTITY|TAG
30+
**BlockNumber** QUANTITY|TAG
3031

3132
* HEX String - an integer block number
3233
* String "earliest" for the earliest/genesis block
3334
* String "latest" - for the latest mined block
3435
* String "safe" - for the latest justified head block
3536
* String "**finalized**" - for the latest finalized block
3637

37-
Boolean
38+
**Full_transaction_flag** Boolean
3839

3940
- If true it returns the full transaction objects, if false only the hashes of the transactions.
4041

@@ -57,7 +58,7 @@ This will return block hashes:
5758
{"jsonrpc":"2.0","id":1,"result":["0x4b52061726b9f15905217699fd5dab8ff9bb704b3b16d27c34541cb15752a91f","0x2b984b80b25f0dddc92ba11290a3d250fc8a3ec6a09bd485c21dbbb8155d2f90"]}
5859
```
5960

60-
## Combined Probabilistic Finality and Economic Finality API
61+
### Combined Probabilistic Finality and Economic Finality API
6162

6263
These methods allow you to handle block finality using a straightforward API.
6364

@@ -81,3 +82,90 @@ curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --dat
8182
8283
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getFinalizedBlock","params":[15, true],"id":1}'
8384
```
85+
86+
## Blob API
87+
88+
### eth_getBlobSidecarByTxHash
89+
**Parameters**
90+
91+
**Hash** String (REQUIRED)
92+
93+
* HEX String - the hash of the transaction
94+
95+
**full_blob_flag** Boolean (OPTIONAL)
96+
97+
* Default is true. If ture it returns the full blob info, if false only return first 32 bytes of blobs.
98+
99+
```
100+
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlobSidecarByTxHash","params":["0x377d3615d2e76f4dcc0c9a1674d2f5487cba7644192e7a4a5af9fe5f08b60a63"],"id":1}'
101+
102+
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlobSidecarByTxHash","params":["0x377d3615d2e76f4dcc0c9a1674d2f5487cba7644192e7a4a5af9fe5f08b60a63", false],"id":1}'
103+
```
104+
105+
### eth_getBlobSidecars
106+
**Parameters**
107+
108+
**BlockNumber** QUANTITY|TAG
109+
110+
* HEX String - an integer block number
111+
* HEX String - the hash of the block
112+
* String "earliest" for the earliest/genesis block
113+
* String "latest" - for the latest mined block
114+
* String "safe" - for the latest justified head block
115+
* String "finalized" - for the latest finalized block
116+
117+
**full_blob_flag** Boolean (OPTIONAL)
118+
119+
* Default is true. If ture it returns the full blob info, if false only return first 32 bytes of blobs.
120+
121+
```
122+
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlobSidecars","params":["latest"],"id":1}'
123+
124+
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlobSidecarByTxHash","params":["0xc5043f", false],"id":1}'
125+
```
126+
127+
128+
129+
## Others
130+
131+
### eth_health
132+
133+
* a health check endpoint to detect whether the RPC func of a node is ok. Return true is ok, false is no health.
134+
135+
136+
```
137+
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_health","params":[],"id":1}'
138+
```
139+
140+
### eth_getTransactionsByBlockNumber
141+
142+
* get all the transactions for the given block number.
143+
144+
**Parameters**
145+
146+
**BlockNumber** QUANTITY|TAG
147+
148+
* HEX String - an integer block number
149+
* String "earliest" for the earliest/genesis block
150+
* String "latest" - for the latest mined block
151+
* String "safe" - for the latest justified head block
152+
* String "finalized" - for the latest finalized block
153+
154+
```
155+
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getTransactionsByBlockNumber","params":["0x539492"],"id":1}'
156+
```
157+
158+
159+
### eth_getTransactionDataAndReceipt
160+
161+
* get the original transaction data and transaction receipt for the given transaction hash.
162+
163+
**Parameters**
164+
165+
**Hash** String (REQUIRED)
166+
167+
* HEX String - the hash of the transaction
168+
169+
```
170+
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getTransactionDataAndReceipt","params":["0x516a2ab1506b020e7f49d0d0ddbc471065624d1a603087262cebf4ca114ff588"],"id":1}'
171+
```

docs/bnb-smart-chain/developers/rpc.md renamed to docs/bnb-smart-chain/developers/json_rpc/json-rpc-endpoint.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
title: RPC - BSC Develop
2+
title: JSON-RPC-Endpoint - BSC Develop
33
---
44

55

6-
# JSON-RPC Endpoint
6+
# JSON-RPC-Endpoint
77

88
JSON-RPC endpoints refers to the network location where a program could transfer its RPC requests to access server data. Once you connect a decentralized application to an RPC endpoint, you can access the functionalities of different operations, which could enable real-time usage of blockchain data. BNB Chain provides several RPC endpoints for connectinto both its Minent and Testnet. In this section, we list the JSON-RPC endpoints that can be used for connecting to BNB Smart Chain.
99

@@ -75,7 +75,26 @@ geth attach https://bsc-dataseed.bnbchain.org
7575
geth attach https://bsc-testnet-dataseed.bnbchain.org
7676
```
7777

78-
### JSON-RPC methods
78+
## JSON-RPC API List
7979

80-
Please refer to this [wiki page](https://github.com/ethereum/wiki/wiki/JSON-RPC) or use Postman: <https://documenter.getpostman.com/view/4117254/ethereum-json-rpc/RVu7CT5J?version=latest>
80+
BSC (BNB Smart Chain) is EVM-compatible and strives to be as compatible as possible with the Go-Ethereum API. However, BSC also has unique features, such as faster finality and the storage of blob data on the execution layer, which require their own specialized APIs.
8181

82+
### Geth(Go-Ethereum) API
83+
84+
BSC is nearly fully compatible with the Geth APIs. Any exceptions or incompatibilities are explicitly listed. If you're looking for detailed usage of a specific API, you will most likely find the answer in the following link:
85+
86+
[Geth JSON-RPC API documentation](https://geth.ethereum.org/docs/interacting-with-geth/rpc).
87+
88+
### Finality
89+
90+
Ethereum's PoS consensus protocol, known as "Gasper," is built on LMD-GHOST (a fork choice rule) and Casper FFG (a finality gadget). Similarly, BSC's consensus protocol, called "Parlia," is constructed on top of a difficulty-based fork choice mechanism with FFG, as described in [BEP-126](https://github.com/bnb-chain/BEPs/blob/master/BEPs/BEP126.md). To further enhance BSC's throughput, validators are allowed to produce multiple consecutive blocks, as explained in [BEP-341](https://github.com/bnb-chain/BEPs/blob/master/BEPs/BEP-341.md). These differences result in BSC having a unique finality process compared to Ethereum. For more details, please refer to the the following doc:
91+
92+
[BSC Finality API](bsc-api-list.md#finality-api).
93+
94+
### Blob
95+
96+
Bsc implement EIP-4844, which support Shard Blob Transactions, as described in [BEP-336](https://github.com/bnb-chain/BEPs/blob/master/BEPs/BEP-336.md). For more details, please refer to the the following doc: [BSC Blob API](bsc-api-list.md#blob-api).
97+
98+
### Other BSC API
99+
100+
Bsc implement some others apis, as described in: [BSC API](bsc-api-list.md#others).

docs/bnb-smart-chain/developers/quick-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Since BSC is EVM-compatible, your existing Ethereum smart contract skills will s
1414

1515
Here are some resources to help you get connected to the BSC network:
1616

17-
- [Network Information and RPC Providers](./rpc.md)
17+
- [Network Information and RPC Providers](json_rpc/json-rpc-endpoint.md)
1818
- [Wallet Configuration](./wallet-configuration.md)
1919

2020
## Get Tokens
@@ -28,7 +28,7 @@ For the mainnet, you can withdraw tokens directly from a centralized exchange (C
2828
## JSON-RPC API
2929

3030
Interacting with BSC requires sending requests to specific JSON-RPC API methods. BSC's APIs are compatible with Geth.
31-
- [JSON-RPC API](./json-rpc-api.md)
31+
- [JSON-RPC API](json_rpc/json-rpc-endpoint.md)
3232

3333
## Developer Tools
3434
- Explorer

docs/bnb-smart-chain/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ title: BNB Smart Chain
5252
<div>Run a Node</div>
5353
<p>Run a BSC node</p>
5454
</a>
55-
<a href="./validator/mev/">
55+
<a href="./validator/mev/overview">
5656
<div>MEV Builder</div>
5757
<p>Become a builder and create blocks and offering them to the validator</p>
5858
</a>
59-
<a href="./developers/json-rpc-api">
60-
<div>JSON-RPC API</div>
59+
<a href="./developers/json_rpc/json-rpc-endpoint">
60+
<div>JSON-RPC-Endpoint</div>
6161
<p>Interacting with BSC requires sending requests to specific JSON-RPC API methods.</p>
6262
</a>
6363
</div>

mkdocs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ nav:
117117
- Developers:
118118
- Quick Guide: ./bnb-smart-chain/developers/quick-guide.md
119119
- Dev-Tools: https://www.bnbchain.org/en/dev-tools
120-
- RPC: ./bnb-smart-chain/developers/rpc.md
120+
- JSON-RPC:
121+
- Json Rpc Endpoint: ./bnb-smart-chain/developers/json_rpc/json-rpc-endpoint.md
122+
- Bsc Api list: ./bnb-smart-chain/developers/json_rpc/bsc-api-list.md
121123
- Faucet: ./bnb-smart-chain/developers/faucet.md
122124
- Node Operators:
123125
- Node Best Practices: ./bnb-smart-chain/developers/node_operators/node_best_practices.md

0 commit comments

Comments
 (0)