# rpc_methods - Moonbeam RPC Method

Returns a list of all RPC methods exposed by the Moonbeam node. This is the definitive way to discover what methods are available on a given endpoint, including both standard Substrate methods and any custom chain-specific extensions.

> **Why Moonbeam?** Build on the cross-chain connected EVM platform on Polkadot with $65M+ TVL and 100+ projects with full EVM compatibility on Polkadot, native XCM cross-chain messaging, 10K+ TPS, 24% staking APR, and $0.015 transaction costs.

## When to Use This Method

`rpc_methods` is essential for cross-chain dApp developers, Polkadot builders, and teams requiring multi-chain interoperability:

- **API Discovery** -- Enumerate all available RPC methods to understand the full capabilities of a Moonbeam node
- **Capability Detection** -- Check whether a specific method (e.g., `author_submitExtrinsic`, `state_call`) is available before calling it
- **Compatibility Testing** -- Verify that an endpoint supports the methods your application requires for cross-chain DeFi, multi-chain dApps, and Ethereum-to-Polkadot bridging via XCM, Axelar, LayerZero, and Wormhole
- **Tooling and Documentation** -- Auto-generate API references or client SDKs from the available method list

## Best Practices

- Call at application startup to discover available RPC capabilities
- Use to gate feature availability -- only call methods that appear in the returned list
- Method availability varies by node configuration and Substrate runtime version
- Verified: a standard Polkadot archive node exposes approximately 129 methods across all namespaces

## Request Parameters

This method accepts no parameters.

## Request Example

```json
{
  "jsonrpc": "2.0",
  "method": "rpc_methods",
  "params": [],
  "id": 1
}
```

## Response Fields

- `methods` (`Array<String>, required`): A sorted list of all available RPC method names

## Successful Response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "methods": [
      "author_pendingExtrinsics",
      "author_submitExtrinsic",
      "chain_getBlock",
      "chain_getBlockHash",
      "chain_getHeader",
      "payment_queryInfo",
      "rpc_methods",
      "state_call",
      "state_getKeysPaged",
      "state_getMetadata",
      "state_getStorage",
      "state_queryStorageAt",
      "system_chain",
      "system_name",
      "system_properties",
      "system_version"
    ]
  }
}
```

## Error Responses

### Error Response

- Code: `-32603`

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32603,
    "message": "Internal error"
  }
}
```

## Code Examples

cURL
JavaScript
Python
Rust

```bash
curl -X POST https://api-moonbeam.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "rpc_methods",
    "params": [],
    "id": 1
  }'
```

```javascript
// Using @polkadot/api
import { ApiPromise, WsProvider } from '@polkadot/api';

const provider = new WsProvider('wss://api-moonbeam.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });

const methods = await api.rpc.rpc.methods();
console.log('Available methods:', methods.methods.length);
methods.methods.forEach((m) => console.log(' -', m.toString()));

await api.disconnect();

// Using fetch (HTTP JSON-RPC)
const response = await fetch('https://api-moonbeam.n.dwellir.com/YOUR_API_KEY', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    jsonrpc: '2.0',
    method: 'rpc_methods',
    params: [],
    id: 1
  })
});

const { result } = await response.json();
console.log(`Found ${result.methods.length} available methods`);
```

```python
import requests

def get_rpc_methods():
    response = requests.post(
        'https://api-moonbeam.n.dwellir.com/YOUR_API_KEY',
        json={
            'jsonrpc': '2.0',
            'method': 'rpc_methods',
            'params': [],
            'id': 1
        }
    )
    return response.json()['result']['methods']

methods = get_rpc_methods()
print(f'Available RPC methods ({len(methods)}):')
for method in methods:
    print(f'  - {method}')

# Using substrate-interface
from substrateinterface import SubstrateInterface

substrate = SubstrateInterface(url='wss://api-moonbeam.n.dwellir.com/YOUR_API_KEY')
result = substrate.rpc_request('rpc_methods', [])['result']
print(f"Methods: {len(result['methods'])}")
```

```rust
use serde_json::json;
use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct RpcMethodsResult {
    methods: Vec<String>,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    let response = client
        .post("https://api-moonbeam.n.dwellir.com/YOUR_API_KEY")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "rpc_methods",
            "params": [],
            "id": 1
        }))
        .send()
        .await?;

    let result: serde_json::Value = response.json().await?;
    let rpc: RpcMethodsResult = serde_json::from_value(result["result"].clone())?;

    println!("Available methods ({}):", rpc.methods.len());
    for method in &rpc.methods {
        println!("  - {}", method);
    }
    Ok(())
}
```

## Common Use Cases

### 1. Endpoint Capability Validation

Check whether a Moonbeam endpoint supports all methods your application needs:

```javascript
async function validateEndpoint(endpoint, requiredMethods) {
  const response = await fetch(endpoint, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'rpc_methods',
      params: [],
      id: 1
    })
  });

  const { result } = await response.json();
  const available = new Set(result.methods);

  const missing = requiredMethods.filter((m) => !available.has(m));

  if (missing.length > 0) {
    console.error('Missing required methods:', missing);
    return false;
  }

  console.log('Endpoint supports all required methods');
  return true;
}

// Usage
await validateEndpoint('https://api-moonbeam.n.dwellir.com/YOUR_API_KEY', [
  'state_getStorage',
  'state_call',
  'author_submitExtrinsic',
  'payment_queryInfo'
]);
```

### 2. Method Category Breakdown

Organize available methods by their RPC namespace:

```javascript
async function getMethodsByCategory(api) {
  const methods = await api.rpc.rpc.methods();
  const categories = {};

  methods.methods.forEach((method) => {
    const name = method.toString();
    const category = name.split('_')[0];
    categories[category] = categories[category] || [];
    categories[category].push(name);
  });

  for (const [category, methodList] of Object.entries(categories)) {
    console.log(`\n${category} (${methodList.length} methods):`);
    methodList.forEach((m) => console.log(`  - ${m}`));
  }

  return categories;
}
```

### 3. Compare Endpoints

Detect differences between two Moonbeam endpoints:

```javascript
async function compareEndpoints(endpoint1, endpoint2) {
  const fetchMethods = async (url) => {
    const res = await fetch(url, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ jsonrpc: '2.0', method: 'rpc_methods', params: [], id: 1 })
    });
    const { result } = await res.json();
    return new Set(result.methods);
  };

  const [methods1, methods2] = await Promise.all([
    fetchMethods(endpoint1),
    fetchMethods(endpoint2)
  ]);

  const onlyIn1 = [...methods1].filter((m) => !methods2.has(m));
  const onlyIn2 = [...methods2].filter((m) => !methods1.has(m));

  if (onlyIn1.length) console.log('Only in endpoint 1:', onlyIn1);
  if (onlyIn2.length) console.log('Only in endpoint 2:', onlyIn2);
  if (!onlyIn1.length && !onlyIn2.length) console.log('Endpoints have identical methods');
}
```

## Related Methods

- [`system_chain`](https://www.dwellir.com/docs/moonbeam/system_chain) -- Get the chain name
- [`system_name`](https://www.dwellir.com/docs/moonbeam/system_name) -- Get the node implementation name
- [`system_version`](https://www.dwellir.com/docs/moonbeam/system_version) -- Get the node implementation version
- [`state_getMetadata`](https://www.dwellir.com/docs/moonbeam/state_getMetadata) -- Get full runtime metadata including pallet and call definitions
