> ## Documentation Index
> Fetch the complete documentation index at: https://luminouslabs-cc5545c6-swen-add-code-runner.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON RPC Methods

> Overview JSON RPC endpoints on Solana, best practices, and error codes.

The API exposed by the indexer closely mirrors existing RPC calls, with one-to-one mapping:

| Solana RPC              | Photon RPC Calls                  |
| :---------------------- | :-------------------------------- |
| getAccountInfo          | getCompressedAccount              |
| getBalance              | getCompressedBalance              |
| getTokenAccountsByOwner | getCompressedTokenAccountsByOwner |
| getProgramAccounts      | getCompressedAccountsByOwner      |

<Card title="View all RPC endpoints for ZK Compression" icon="chevron-right" color="#0066ff" href="/api-reference/json-rpc-methods/methods" horizontal />

## Create an RPC Connection

<Tabs>
  <Tab title="Mainnet">
    ```typescript highlight={6-7} theme={null}
    import {
      Rpc,
      createRpc,
    } from "@lightprotocol/stateless.js";

    // Helius exposes Solana and Photon RPC endpoints through a single URL
    const RPC_ENDPOINT = "https://mainnet.helius-rpc.com?api-key=<api_key>";
    const PHOTON_ENDPOINT = RPC_ENDPOINT;
    const PROVER_ENDPOINT = RPC_ENDPOINT;
    const connection: Rpc = createRpc(RPC_ENDPOINT, PHOTON_ENDPOINT, PROVER_ENDPOINT)

    console.log("connection", connection);
    ```
  </Tab>

  <Tab title="Devnet">
    ```typescript highlight={6-7} theme={null}
    import {
      Rpc,
      createRpc,
    } from "@lightprotocol/stateless.js";

    // Helius exposes Solana and Photon RPC endpoints through a single URL
    const RPC_ENDPOINT = "https://devnet.helius-rpc.com?api-key=<api_key>";
    const PHOTON_ENDPOINT = RPC_ENDPOINT;
    const PROVER_ENDPOINT = RPC_ENDPOINT;
    const connection: Rpc = createRpc(RPC_ENDPOINT, PHOTON_ENDPOINT, PROVER_ENDPOINT)

    console.log("connection", connection);
    ```
  </Tab>
</Tabs>

## Best Practices

| Best Practice         | Description                                                                                                   |
| :-------------------- | :------------------------------------------------------------------------------------------------------------ |
| **Commitment Levels** | Use appropriate commitment levels: `processed` (fastest), `confirmed` (balanced), `finalized` (most reliable) |
| **Rate Limiting**     | Implement retry logic and respect rate limits. Public endpoints: 100 req/s, Private: 1000+ req/s              |
| **Batch Requests**    | Use batch requests when possible to improve efficiency and reduce API calls                                   |
| **Caching**           | Cache frequently accessed data to reduce API calls and improve performance                                    |

## Error Codes

<Tip>
  <div style={{display: "flex", alignItems: "center", padding: 0, margin: 0}}>
    <span style={{margin: 0, padding: 0, marginLeft: "8px"}}>For help with debugging use</span>

    <a href="https://deepwiki.com/Lightprotocol/light-protocol/3.3-rpc-and-indexer-integration" style={{padding: 0, margin: 0, display: "inline-block"}}>
      <img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki" style={{padding:0, margin:0, verticalAlign: "middle"}} />
    </a>
  </div>
</Tip>

| Code   | Message              | Description                                  |
| :----- | :------------------- | :------------------------------------------- |
| -32600 | Invalid Request      | The JSON sent is not a valid Request object  |
| -32601 | Method not found     | The method does not exist / is not available |
| -32602 | Invalid params       | Invalid method parameter(s)                  |
| -32603 | Internal error       | Internal JSON-RPC error                      |
| -32000 | Account not found    | The compressed account was not found         |
| -32001 | Invalid account hash | The provided account hash is invalid         |

# Next Steps

<Card title="View all RPC endpoints for ZK Compression" icon="chevron-right" color="#0066ff" href="/api-reference/json-rpc-methods/methods" horizontal />
