> For the complete documentation index, see [llms.txt](https://docs.chainrpc.io/chainrpc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chainrpc.io/chainrpc/networks/ethereum/json-rpc-methods.md).

# JSON-RPC methods

This section lists the Ethereum JSON-RPC API endpoints. You can call these APIs using a variety of tools. These APIs (or a subset of them) are also used by some Ethereum-compatible networks such as:

* ​Arbitrum​
* ​Optimism​
* ​Polygon PoS​
* ​Palm​
* ​Aurora​
* ​Avalanche (C-Chain)​
* ​Celo​

### Error codes <a href="#error-codes" id="error-codes"></a>

The following list contains all possible error codes and associated messages:

<table><thead><tr><th width="114">Code</th><th width="221">Message</th><th>Meaning</th><th>Category</th><th></th></tr></thead><tbody><tr><td>-32700</td><td>Parse error</td><td>Invalid JSON</td><td>standard</td><td>​</td></tr><tr><td>-32600</td><td>Invalid request</td><td>JSON is not a valid request object</td><td>standard</td><td>​</td></tr><tr><td>-32601</td><td>Method not found</td><td>Method does not exist</td><td>standard</td><td>​</td></tr><tr><td>-32602</td><td>Invalid params</td><td>Invalid method parameters</td><td>standard</td><td>​</td></tr><tr><td>-32603</td><td>Internal error</td><td>Internal JSON-RPC error</td><td>standard</td><td>​</td></tr><tr><td>-32000</td><td>Invalid input</td><td>Missing or invalid parameters</td><td>non-standard</td><td>​</td></tr><tr><td>-32001</td><td>Resource not found</td><td>Requested resource not found</td><td>non-standard</td><td>​</td></tr><tr><td>-32002</td><td>Resource unavailable</td><td>Requested resource not available</td><td>non-standard</td><td>​</td></tr><tr><td>-32003</td><td>Transaction rejected</td><td>Transaction creation failed</td><td>non-standard</td><td>​</td></tr><tr><td>-32004</td><td>Method not supported</td><td>Method is not implemented</td><td>non-standard</td><td>​</td></tr><tr><td>-32005</td><td>Limit exceeded</td><td>Request exceeds defined limit</td><td>non-standard</td><td>​</td></tr><tr><td>-32006</td><td>JSON-RPC version not supported</td><td>Version of JSON-RPC protocol is not supported</td><td>non-standard</td><td>​</td></tr></tbody></table>

Example error response:{"id": 1337"jsonrpc": "2.0","error": {"code": -32003,"message": "Transaction rejected"}}

### Value encoding <a href="#value-encoding" id="value-encoding"></a>

Specific types of values passed to and returned from Ethereum RPC methods require special encoding:

#### Quantity <a href="#quantity" id="quantity"></a>

A `Quantity` (integer, number) must:

* Be hex-encoded.
* Be "0x"-prefixed.
* Be expressed using the fewest possible hex digits per byte.
* Express zero as "0x0".

Examples `Quantity` values:

| Value  | Validity  | Reason                            |
| ------ | --------- | --------------------------------- |
| 0x     | `invalid` | empty not a valid quantity        |
| 0x0    | `valid`   | interpreted as a quantity of zero |
| 0x00   | `invalid` | leading zeroes not allowed        |
| 0x41   | `valid`   | interpreted as a quantity of 65   |
| 0x400  | `valid`   | interpreted as a quantity of 1024 |
| 0x0400 | `invalid` | leading zeroes not allowed        |
| ff     | `invalid` | values must be prefixed           |

#### Block identifier <a href="#block-identifier" id="block-identifier"></a>

The RPC methods below take a default block identifier as a parameter.

* `eth_getBalance`
* `eth_getStorageAt`
* `eth_getTransactionCount`
* `eth_getCode`
* `eth_call`
* `eth_getProof`

Since there is no way to clearly distinguish between a `Data` parameter and a `Quantity` parameter, [EIP-1898](https://eips.ethereum.org/EIPS/eip-1898) provides a format to specify a block either using the block hash or block number. The block identifier is a JSON `object` with the following fields:

| Property           | Type                                                     | Description                                                                                                                                                                           |
| ------------------ | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `[blockNumber]`    | {[`Quantity`](https://infura.io/docs/ethereum#quantity)} | The block in the canonical chain with this number                                                                                                                                     |
| OR `[blockHash]`   | {[`Data`](https://infura.io/docs/ethereum#data)}         | The block uniquely identified by this hash. The `blockNumber` and `blockHash` properties are mutually exclusive; exactly one of them must be set.                                     |
| `requireCanonical` | {`boolean`}                                              | (optional) Whether or not to throw an error if the block is not in the canonical chain as described below. Only allowed in conjunction with the `blockHash` tag. Defaults to `false`. |

#### Data <a href="#data" id="data"></a>

A `Data` value (for example, byte arrays, account addresses, hashes, and bytecode arrays) must:

* Be hex-encoded.
* Be "0x"-prefixed.
* Be expressed using two hex digits per byte.

Examples `Data` values:

| Value    | Valid     | Reason                                             |
| -------- | --------- | -------------------------------------------------- |
| 0x       | `valid`   | interpreted as empty data                          |
| 0x0      | `invalid` | each byte must be represented using two hex digits |
| 0x00     | `valid`   | interpreted as a single zero byte                  |
| 0x41     | `true`    | interpreted as a data value of 65                  |
| 0x004200 | `true`    | interpreted as a data value of 16896               |
| 0xf0f0f  | `false`   | bytes require two hex digits                       |
| 004200   | `false`   | values must be prefixed                            |
