# JSON-RPC Server

The JSON-PRC Server provides an API that allows you to connect to the Metanovaverse blockchain and interact with the EVM. This gives you direct access to reading Ethereum-formatted transactions or sending them to the network which otherwise wouldn't be possible on a Cosmos chain, such as Metanovaverse.

[JSON-RPC](http://www.jsonrpc.org/specification) is a stateless, light-weight remote procedure call (RPC) protocol. It defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments. It uses JSON ([RFC 4627](https://www.ietf.org/rfc/rfc4627.txt)) as data format.

JSON-RPC is provided on multiple transports. Metanovaverse supports JSON-RPC over HTTP and WebSocket. Transports must be enabled through command-line flags or through the `app.toml` configuration file.

### Web3 Support <a href="#web3-support" id="web3-support"></a>

Metanovaverse supports all standard web3 JSON-RPC APIs. You can find documentation for these APIs on the `JSON-RPC Methods` page.

Ethereum JSON-RPC APIs use a name-space system. RPC methods are grouped into several categories depending on their purpose.&#x20;

All method names are composed of the namespace, an underscore, and the actual method name within the namespace. For example, the eth\_call method resides in the eth namespace. Access to RPC methods can be enabled on a per-namespace basis.&#x20;

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

At present there are two key datatypes that are passed over JSON:

* **quantities** and
* **unformatted byte arrays**.

Both are passed with a hex encoding, however with different requirements to formatting.

When encoding quantities (integers, numbers), encode as hex, prefix with `"0x"`, the most compact representation (slight exception: zero should be represented as `"0x0"`). Examples:

* `0x41` (65 in decimal)
* `0x400` (1024 in decimal)
* WRONG: `0x` (should always have at least one digit - zero is `"0x0"`)
* WRONG: `0x0400` (no leading zeroes allowed)
* WRONG: `ff` (must be prefixed `0x`)

When encoding unformatted data (byte arrays, account addresses, hashes, bytecode arrays), encode as hex, prefix with `"0x"`, two hex digits per byte. Examples:

* `0x41` (size 1, `"A"`)
* `0x004200` (size 3, `"\0B\0"`)
* `0x` (size 0, `""`)
* WRONG: `0xf0f0f` (must be even number of digits)
* WRONG: `004200` (must be prefixed `0x`)

### Default block parameter <a href="#default-block-parameter" id="default-block-parameter"></a>

The following methods have an extra default block parameter:

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

When requests are made that act on the state of Metanovaverse, the last default block parameter determines the height of the block.

The following options are possible for the `defaultBlock` parameter:

* `HEX String` - an integer block number
* `String "earliest"` for the earliest/genesis block
* `String "latest"` - for the latest mined block
* `String "pending"` - for the pending state/transactions

### Curl Examples Explained <a href="#curl-examples-explained" id="curl-examples-explained"></a>

The curl options below might return a response where the node complains about the content type, this is because the `--data` option sets the content type to `application/x-www-form-urlencoded`. If your node does complain, manually set the header by placing `-H "Content-Type: application/json"` at the start of the call.

The examples also do not include the URL/IP & port combination which must be the last argument given to curl e.x. `127.0.0.1:8545`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.metanovaverse.com/dapp-developers/ethereum-json-rpc/json-rpc-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
