> ## Documentation Index
> Fetch the complete documentation index at: https://docs.presschain.io/llms.txt
> Use this file to discover all available pages before exploring further.

# RPC

> Connect applications and infrastructure to PressChain using Ethereum-compatible JSON-RPC.

# RPC

PressChain V3 exposes an Ethereum-compatible JSON-RPC surface at the canonical public endpoint:

```text theme={null}
https://rpc.presschain.io
```

The RPC is the most direct read path into chain state and the transport used for signed transaction submission. Application APIs and indexers can make higher-level queries easier, but they do not replace JSON-RPC as the underlying protocol interface.

## Basic request

JSON-RPC requests are HTTP `POST` bodies with a protocol version, request ID, method and parameter array.

```bash theme={null}
curl -s https://rpc.presschain.io \
  -H 'content-type: application/json' \
  --data '{
    "jsonrpc":"2.0",
    "id":1,
    "method":"eth_blockNumber",
    "params":[]
  }'
```

A healthy response returns a hexadecimal block number in `result`.

## Useful read methods

Developers building a PressChain client will commonly use standard Ethereum RPC methods such as:

| Method                      | Purpose                                                      |
| --------------------------- | ------------------------------------------------------------ |
| `eth_chainId`               | verify that the client is connected to PressChain V3 testnet |
| `eth_blockNumber`           | observe current chain height                                 |
| `eth_getBalance`            | inspect native balance for an address                        |
| `eth_call`                  | execute read-only contract calls                             |
| `eth_getLogs`               | retrieve contract events for indexing                        |
| `eth_getTransactionByHash`  | inspect a submitted transaction                              |
| `eth_getTransactionReceipt` | determine transaction inclusion and status                   |
| `eth_getTransactionCount`   | obtain a nonce for transaction construction                  |
| `eth_estimateGas`           | estimate gas for a prepared call                             |
| `eth_gasPrice`              | obtain a network gas price signal                            |
| `eth_sendRawTransaction`    | submit a transaction that has already been signed            |

## Browser use

For user actions, prefer PressKey rather than sending unsigned transaction material to your own server.

```ts theme={null}
const provider = window.presschain;
const chainId = await provider.request({ method: "eth_chainId" });
const accounts = await provider.request({ method: "eth_accounts" });

console.log({ chainId, accounts });
```

PressKey exposes an EIP-style request API and maps its network state to PressChain Chain ID `77117002`.

## Server-side reads

Servers can use the public RPC for reads and indexing without holding a user key. A simple Node read helper looks like this:

```ts theme={null}
const RPC = "https://rpc.presschain.io";
let id = 0;

export async function rpc(method: string, params: unknown[] = []) {
  const response = await fetch(RPC, {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify({ jsonrpc: "2.0", id: ++id, method, params }),
  });

  if (!response.ok) throw new Error(`RPC HTTP ${response.status}`);
  const payload = await response.json();
  if (payload.error) throw new Error(payload.error.message ?? "RPC error");
  return payload.result;
}
```

This helper is suitable for reads. It is not a reason to add user private keys to the backend.

## Production behavior

Treat RPC as network infrastructure, not a function call that can never fail. Set request timeouts. Retry safe reads with bounded backoff. Do not blindly retry `eth_sendRawTransaction` without understanding whether the original signed transaction was accepted.

When a write request times out, query the transaction hash or sender nonce before generating a different transaction. Duplicate submission and nonce races are application concerns even when the RPC itself is healthy.

## Indexing with logs

An indexer should read events in bounded block ranges and store the block number, block hash, transaction hash and log index with every projected event. The tuple of transaction hash and log index is useful for idempotency, while block hash lets the projection detect reorganization.

Do not assume a log is permanently final simply because it was returned once. Your finality policy should be explicit and appropriate to the environment.

## Endpoint authority

The V3 platform authority names `https://rpc.presschain.io` as the canonical public RPC. Client-specific proxies may exist, but they should not quietly become the protocol source of truth. PressKey source, for example, can use a web proxy as an implementation detail. Application documentation should still identify the canonical network endpoint from the current authority configuration.
