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

rpc_modules - Optimism

Example code for the rpc_modules json-rpc method. Сomplete guide on how to use rpc_modules json-rpc in GetBlock.io Web3 documentation.

This method returns an object listing all available RPC modules and their versions. This is useful for determining which methods are available on a particular node and for debugging connectivity issues.

Parameters

  • None

Request Sample

curl --location 'https://go.getblock.us/<ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
   "jsonrpc": "2.0",
    "method": "rpc_modules",
    "params": []
    "id": "getblock.io"
}'
import axios from 'axios'
let data = JSON.stringify({
    "jsonrpc": "2.0",
    "method": "rpc_modules",
    "params": [],
    "id": "getblock.io"
};

let config = {
  method: "post",
  maxBodyLength: Infinity,
  url: "https://go.getblock.us/<ACCESS_TOKEN>",
  headers: {
    "Content-Type": "application/json",
  },
  data: data,
};

axios
  .request(config)
  .then((response) => {
    console.log(JSON.stringify(response.data));
  })
  .catch((error) => {
    console.log(error);
  });

Response

A successful response returns the following:

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "eth": "1.0",
        "net": "1.0",
        "web3": "1.0",
        "debug": "1.0",
        "trace": "1.0"
    }
}

Response Parameters

  • id: A unique request identifier, matching the id sent in the request body.

  • jsonrpc: Specifies the use of JSON-RPC version 2.0.

  • result: An object mapping module names to their version strings.

Use Case

The rpc_modules method is commonly used for:

  • Module discovery

  • API capability checking

  • Debugging

  • Infrastructure documentation

Error handling

Status Code
Error Message
Cause

404

Not found

Missing or invalid ACCESS_TOKEN.

Integration with Web3

Using rpc_modules allows developers to:

  • Tools adapt automatically based on enabled modules.

  • Ensures required RPC namespaces exist before dApp initialization.

  • Helps compare feature sets across RPC providers.

Last updated

Was this helpful?