# On-chain data at a specific blockhash

Ternoa-js provides the capability to query chain state at a specific/custom passed blockhash

{% hint style="info" %}
If you are not familiar with the process of creating a transaction on the Ternoa chain, we highly suggest first reading the Getting Started section of the documentation with a focus on:&#x20;

* [The Ternoa-js architecture ](/getting-started/javascript-sdk/ternoa-js-library/architecture.md)
* [The Ternoa-js workflow](/getting-started/javascript-sdk/ternoa-js-library/workflow.md)
  {% endhint %}

{% hint style="info" %}
To learn more about how to access the Ternoa-js API & make custom interactions with the Ternoa chain read these sections:&#x20;

* [Access Ternoa API](/build-1/javascript/ternoa-js-library-utilities/installation-and-initialization.md#accessing-the-ternoa-api)
* [Make custom requests](/build-1/javascript/ternoa-js-library-utilities/customs-extrinsics-and-queries.md)
  {% endhint %}

```typescript
const api = getRawApi()
const lastHeader = await api.rpc.chain.getHeader();
const apiAt = await api.at(lastHeader.hash);
```

Once you have access to the apiAt a specific blockhash, you can perform any operation. For example to query a balance:&#x20;

```typescript
 const balance = await apiAt.query.system.account("//REPLACE BY THE ADRESS");
```

{% hint style="info" %}
Useful resources from Polkadot{.js} documentation:&#x20;

* [Read storage, at a specific blockhash](https://polkadot.js.org/docs/api/examples/promise/read-storage-at)
* [State at a specific block](https://polkadot.js.org/docs/api/start/api.query.other/#state-at-a-specific-block)
  {% endhint %}


---

# 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.ternoa.network/build-1/javascript/ternoa-js-library-utilities/on-chain-data-at-a-specific-blockhash.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.
