JSON-RPC basics
Shared JSON-RPC 2.0 request, notification, batch, success, and error conventions used by MegaETH.
Last updated
Shared JSON-RPC 2.0 request, notification, batch, success, and error conventions used by MegaETH.
MegaETH uses JSON-RPC 2.0 for HTTP requests and WebSocket messages. Method pages define the parameter order, result shape, and method-specific behavior.
jsonrpc
string
Yes
Must be "2.0".
id
string or number
Unless sending a notification
Correlates the response with the request.
method
string
Yes
Names the RPC method.
params
array or object
Method-defined
Method pages in this reference use positional arrays.
Use a unique string or number for id when you expect a response. JSON-RPC permits a null request ID, but clients should avoid it because a response may also use null when the request ID cannot be determined.
{
"jsonrpc": "2.0",
"id": 1,
"method": "eth_chainId",
"params": []
}A notification omits id. The server does not return a response, including when the notification is invalid.
{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": []
}Use notifications only when your application intentionally does not need a result or error.
A batch is a JSON array containing request or notification objects. The public gateway accepts at most 100 items in one batch.
Batch responses may arrive in a different order from their requests. Match each response by id, and remember that notification items do not produce response items. See Operations and limits for batch accounting and body-size limits.
A successful response contains result and does not contain error. The result type is defined by the method.
Values such as null, "0x0", and [] can be successful results when documented by the method.
A failed call contains error and does not contain result.
jsonrpc
string
Yes
Always "2.0".
id
string, number, or null
Yes
Usually matches the request ID.
error.code
number
Yes
Machine-readable error code.
error.message
string
Yes
Human-readable summary.
error.data
any
No
Additional structured details.
HTTP 200 only means the HTTP exchange completed. Always inspect the JSON-RPC body for result or error. See Error reference for standard, Ethereum, gateway, and MegaETH-specific codes.
Last updated
[
{
"jsonrpc": "2.0",
"id": "block",
"method": "eth_blockNumber",
"params": []
},
{
"jsonrpc": "2.0",
"id": "chain",
"method": "eth_chainId",
"params": []
}
]{
"jsonrpc": "2.0",
"id": 1,
"result": "0x10e6"
}{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32602,
"message": "Invalid params"
}
}