For the complete documentation index, see llms.txt. This page is also available as Markdown.

JSON-RPC basics

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.

Request envelope

Field
JSON type
Required
Rule

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": []
}

Notifications

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.

Batch requests

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.

Success response

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.

Error response

A failed call contains error and does not contain result.

Field
JSON type
Required
Description

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.

Sources

Last updated