Skip to content

Commit

Permalink
Update rpc doc
Browse files Browse the repository at this point in the history
  • Loading branch information
blxdyx authored and zlacfzy committed Sep 25, 2024
1 parent bef841b commit 30de250
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 30 deletions.
17 changes: 0 additions & 17 deletions docs/bnb-smart-chain/developers/json-rpc-api.md

This file was deleted.

45 changes: 45 additions & 0 deletions docs/bnb-smart-chain/developers/json_rpc/blob-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: Blob API - BSC Develop
---


## Blob API

### eth_getBlobSidecarByTxHash
**Parameters**

**Hash** String (REQUIRED)

* HEX String - the hash of the transaction

**full_blob_flag** Boolean (OPTIONAL)

* Default is true. If ture it returns the full blob info, if false only return first 32 bytes of blobs.

```
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlobSidecarByTxHash","params":["0x377d3615d2e76f4dcc0c9a1674d2f5487cba7644192e7a4a5af9fe5f08b60a63"],"id":1}'
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlobSidecarByTxHash","params":["0x377d3615d2e76f4dcc0c9a1674d2f5487cba7644192e7a4a5af9fe5f08b60a63", false],"id":1}'
```

### eth_getBlobSidecars
**Parameters**

**BlockNumber** QUANTITY|TAG

* HEX String - an integer block number
* HEX String - the hash of the block
* String "earliest" for the earliest/genesis block
* String "latest" - for the latest mined block
* String "safe" - for the latest justified head block
* String "**finalized**" - for the latest finalized block

**full_blob_flag** Boolean (OPTIONAL)

* Default is true. If ture it returns the full blob info, if false only return first 32 bytes of blobs.

```
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlobSidecars","params":["latest"],"id":1}'
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlobSidecarByTxHash","params":["0xc5043f", false],"id":1}'
```
49 changes: 49 additions & 0 deletions docs/bnb-smart-chain/developers/json_rpc/bsc-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Bsc API - BSC Develop
---


## Bsc API

### eth_health

* a health check endpoint to detect whether the RPC func of a node is ok. Return true is ok, false is no health.


```
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_health","params":[],"id":1}'
```

### eth_getTransactionsByBlockNumber

* get all the transactions for the given block number.

**Parameters**

**BlockNumber** QUANTITY|TAG

* HEX String - an integer block number
* String "earliest" for the earliest/genesis block
* String "latest" - for the latest mined block
* String "safe" - for the latest justified head block
* String "**finalized**" - for the latest finalized block

```
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getTransactionsByBlockNumber","params":["0x539492"],"id":1}'
```


### eth_getTransactionDataAndReceipt

* get the original transaction data and transaction receipt for the given transaction hash.

**Parameters**

**Hash** String (REQUIRED)

* HEX String - the hash of the transaction

```
curl -X POST "http://localhost:8545/" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getTransactionDataAndReceipt","params":["0x516a2ab1506b020e7f49d0d0ddbc471065624d1a603087262cebf4ca114ff588"],"id":1}'
```

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Economic Finality refers to the high cost associated with reverting a block. In
### [eth_getHeaderByNumber](<https://www.quicknode.com/docs/kaia/eth_getHeaderByNumber>) as in the Ethereum client.
**Parameters**

QUANTITY|TAG
**BlockNumber** QUANTITY|TAG

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

QUANTITY|TAG
**BlockNumber** QUANTITY|TAG

* HEX String - an integer block number
* String "earliest" for the earliest/genesis block
* String "latest" - for the latest mined block
* String "safe" - for the latest justified head block
* String "**finalized**" - for the latest finalized block

Boolean
**Full_transaction_flag** Boolean

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: RPC - BSC Develop
title: JSON-RPC - BSC Develop
---


# JSON-RPC Endpoint
# JSON-RPC

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.

Expand Down Expand Up @@ -73,7 +73,26 @@ geth attach https://bsc-dataseed.bnbchain.org
geth attach https://bsc-testnet-dataseed.bnbchain.org
```

### JSON-RPC methods
## JSON-RPC API List

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>
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.

### Geth(Go-Ethereum) API

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:

[Geth JSON-RPC API documentation](https://geth.ethereum.org/docs/interacting-with-geth/rpc).

### Finality

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:

[BSC Finality API](finality-api.md).

### Blob

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](blob-api.md).

### Other BSC API

Bsc implement some others apis, as described in: [BSC API](bsc-api.md).
4 changes: 2 additions & 2 deletions docs/bnb-smart-chain/developers/quick-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Since BSC is EVM-compatible, your existing Ethereum smart contract skills will s

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

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

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

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

## Developer Tools
- Explorer
Expand Down
6 changes: 3 additions & 3 deletions docs/bnb-smart-chain/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ title: BNB Smart Chain
<div>Run a Node</div>
<p>Run a BSC node</p>
</a>
<a href="./validator/mev/">
<a href="./validator/mev/overview">
<div>MEV Builder</div>
<p>Become a builder and create blocks and offering them to the validator</p>
</a>
<a href="./developers/json-rpc-api">
<div>JSON-RPC API</div>
<a href="./developers/json_rpc/json-rpc">
<div>JSON-RPC</div>
<p>Interacting with BSC requires sending requests to specific JSON-RPC API methods.</p>
</a>
</div>
6 changes: 5 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ nav:
- Developers:
- Quick Guide: ./bnb-smart-chain/developers/quick-guide.md
- Dev-Tools: https://www.bnbchain.org/en/dev-tools
- RPC: ./bnb-smart-chain/developers/rpc.md
- JSON-RPC:
- Json Rpc: ./bnb-smart-chain/developers/json_rpc/json-rpc.md
- Finality Api: ./bnb-smart-chain/developers/json_rpc/finality-api.md
- Blob Api: ./bnb-smart-chain/developers/json_rpc/blob-api.md
- Bsc Api: ./bnb-smart-chain/developers/json_rpc/bsc-api.md
- Faucet: ./bnb-smart-chain/developers/faucet.md
- Node Operators:
- Node Best Practices: ./bnb-smart-chain/developers/node_operators/node_best_practices.md
Expand Down

0 comments on commit 30de250

Please sign in to comment.