> For the complete documentation index, see [llms.txt](https://docs.eniac.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eniac.network/build/smart-contracts/querying-state.md). Agents can also search and read this documentation through its [MCP server](https://docs.eniac.network/~gitbook/mcp).

# Querying State

## Querying Blockchain State

Querying the blockchain state to retrieve account balances, token balances, and other information is essential.

### Querying State

All nodes contain the latest blockchain state. This means you can query the blockchain state by connecting to an RPC node. There are three primary methods to query a node:

* RPC Endpoint
* gRPC Endpoint
* REST Endpoint
* Websockets

### Querying Historical State

When working with blockchain applications, querying historical state data is crucial for various types of applications. To query historical state data, you can use an archive node and specify the block height at which you want to retrieve the state.

• **Example**: To query the state at a specific block height, you can use the following method:

Querying with enid by block height

`enid query bank balances [address] --height <block-height>`

• This command allows you to specify a block height and retrieve the state at that specific point in time.

### **Pruning**

Pruning is the process of removing old blockchain data that is no longer needed to save disk space and improve performance. Pruned nodes retain only a limited amount of recent blockchain data, making them faster and less storage-intensive for RPC providers.

• **Purpose**: Pruning helps reduce the storage requirements of a blockchain node, making it more efficient and easier to manage.

• **Limitation**: Pruned nodes do not retain the full blockchain history, so they cannot be used to query historical data beyond the pruning window.

### **Archive Nodes**

On the other hand, archive nodes store the entire blockchain history from the genesis block to the latest block. This makes them essential for querying historical state data.

• **Purpose**: Archive nodes preserve the complete blockchain history, allowing developers to query any past state by block height.

• **Use Cases**: Archive nodes are critical for tasks requiring access to historical data, such as catching up indexers, conducting historical analysis, and verifying past transactions.

### **Using Indexers for Historical Data**

While archive nodes provide raw historical data, indexers are vital for efficiently querying and analyzing this data. Indexers organize and optimize the data, making it more accessible and easier to analyze.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.eniac.network/build/smart-contracts/querying-state.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
