Skip to content

Commit bb60fe1

Browse files
docs: add request batching example (#404)
Adds an example for batching JSON-RPC requests
1 parent 09bb648 commit bb60fe1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

content/20.zksync-protocol/10.api/10.conventions.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Here are some examples:
2222
- WRONG: ff (must be prefixed 0x)
2323

2424
### Unformatted data
25+
2526
When encoding unformatted data (byte arrays, account addresses, hashes, bytecode arrays):
2627
encode as hex, prefix with "0x", two hex digits per byte.
2728

@@ -55,3 +56,30 @@ The following options are possible for the defaultBlock parameter:
5556
- String "safe" - for the latest safe head block
5657
- String "finalized" - for the latest finalized block
5758
- String "pending" - for the pending state/transactions
59+
60+
## Batching JSON-RPC Requests
61+
62+
JSON-RPC requests can be batched together.
63+
64+
Example batched request:
65+
66+
```bash
67+
curl https://sepolia.era.zksync.dev -X POST -H "Content-Type: application/json" --data '[{"jsonrpc": "2.0", "id": 1, "method": "eth_estimateGas", "params": [{"from": "0x03AC0b1b952C643d66A4Dc1fBc75118109cC074C"}]},{"jsonrpc": "2.0", "id": 2, "method": "eth_gasPrice", "params": []}]' | jq
68+
```
69+
70+
Example response:
71+
72+
```bash
73+
[
74+
{
75+
"jsonrpc": "2.0",
76+
"result": "0x9dfe4",
77+
"id": 1
78+
},
79+
{
80+
"jsonrpc": "2.0",
81+
"result": "0x17d7840",
82+
"id": 2
83+
}
84+
]
85+
```

0 commit comments

Comments
 (0)