# Blockchain Queries

The ToroForge Node.js SDK provides access to **on-chain data** from the Toronet blockchain — allowing developers to build block explorers, track transactions, and monitor network health in real time.

***

### 🧾 What You Can Query

* Latest blockchain status
* Most recent block data
* Recent on-chain transactions
* Historical block information
* Current exchange rates for supported tokens

***

### 📟 Get Blockchain Status

Returns general metadata about the current blockchain state.

```ts
import { getBlockchainStatus } from 'torosdk';

const status = await getBlockchainStatus();

console.log(status);
/*
{
  lastblock: '45021',
  peers: 4,
  pendingtx: 2,
  status: 'online'
}
*/
```

***

### ⛓️ Get Latest Block Data

Retrieve metadata about the most recent block.

```ts
import { getLatestBlockData } from 'torosdk';

const latestBlock = await getLatestBlockData();
```

***

### 📦 Get Recent Transactions

Get a list of the most recent blockchain transactions.

```ts
import { getBlockchainTransactions } from 'torosdk';

const transactions = await getBlockchainTransactions(10); // Fetch last 10 txs
```

***

### 📚 Get Historical Block Data

Query any specific number of recent blocks.

```ts
import { getBlocksData } from 'torosdk';

const blocks = await getBlocksData(5); // Last 5 blocks
```

Each block includes details such as:

* Timestamp
* Block height
* Transactions
* Hashes
* Block creator

***

### 💱 Get Exchange Rates

Returns the latest known exchange rates between fiat and ToroG.

```ts
import { getSupportedAssetsExchangeRates } from 'torosdk';

const rates = await getSupportedAssetsExchangeRates();
```

Example response:

```ts
{
  NGN: 1,
  USD: 0.014,
  KSH: 1.85
}
```

Use this data to:

* Display fiat → token conversion
* Calculate deposits or rewards
* Validate exchange values

***

### 🧠 Use Cases

* Build a **block explorer interface**
* Display **live block activity** on dashboards
* Provide **transaction history** inside user apps
* Integrate **real-time token pricing**

***

### ⚠️ Tips

* Always implement retry or fallback logic — nodes may rate-limit requests.
* You may cache block results to avoid unnecessary network calls in frontend apps.
* Use `getBlockchainTransactions` only when you need general network activity (not tied to a specific address).

***

### 🔗 Related Docs

* [Wallet Management](https://chatgpt.com/c/wallets.md)
* [Fiat Deposits](https://chatgpt.com/c/deposits.md)
* [Token Balances](https://chatgpt.com/c/balances.md)


---

# 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://toroforges-organization.gitbook.io/toroforge-collective/getting-started/sdks/javascript/blockchain-queries.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.
