RPC Methods
Overview
Testnet 122606
Section
RPC Methods
Documentation category
Type
Guide
Technical reference
Summary
JSON-RPC 2.0 request and response format, supported method categories, and batch calls.
Article Content
JSON-RPC 2.0
SWSS Chain implements the JSON-RPC 2.0 specification. All calls use POST to the RPC endpoint with a JSON body.
Request Format
{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}
| Field | Type | Description |
|---|---|---|
| jsonrpc | string | Always "2.0" |
| method | string | The RPC method name |
| params | array | Method parameters (may be empty) |
| id | number/string | Request identifier, echoed in response |
Response Format
Success:
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x12D687"
}
Error:
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32602,
"message": "Invalid params"
}
}
Supported Method Categories
| Category | Methods |
|---|---|
| Chain | eth_chainId, net_version, net_peerCount |
| Blocks | eth_blockNumber, eth_getBlockByNumber, eth_getBlockByHash |
| Accounts | eth_getBalance, eth_getTransactionCount |
| Transactions | eth_sendRawTransaction, eth_getTransactionByHash, eth_getTransactionReceipt |
| Gas | eth_gasPrice, eth_estimateGas |
| Contracts | eth_call, eth_getLogs |
Batch Requests
You may send multiple requests in a single HTTP call by wrapping them in a JSON array:
[
{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1},
{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":2}
]
