> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usexfg.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Daemon RPC: Query Blocks and Chain Data

> JSON-RPC methods for querying Fuego block data: getblockcount, getblockhash, getblocktemplate, getlastblockheader, and related endpoints.

The Fuego daemon exposes a set of JSON-RPC methods for querying and interacting with block data. You send these as `POST` requests to `http://127.0.0.1:18180/json_rpc` with a standard JSON-RPC 2.0 envelope. These methods let you poll chain height, fetch block headers by hash or height, retrieve templates for mining, and submit solved blocks to the network.

***

## getblockcount

Returns the current number of blocks in the main chain (i.e. the current height).

### Request

<ParamField body="method" type="string" required>
  `"getblockcount"`
</ParamField>

<ParamField body="params" type="object" required>
  Empty object `{}` — this method takes no parameters.
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl -s http://127.0.0.1:18180/json_rpc \
    -H 'Content-Type: application/json' \
    -d '{
      "jsonrpc": "2.0",
      "method": "getblockcount",
      "params": {},
      "id": "1"
    }'
  ```

  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "method": "getblockcount",
    "params": {},
    "id": "1"
  }
  ```
</CodeGroup>

### Response

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "1",
  "result": {
    "count": 900000,
    "status": "OK"
  }
}
```

<ResponseField name="count" type="integer" required>
  The total number of blocks in the main chain. Also the index of the next block to be mined.
</ResponseField>

<ResponseField name="status" type="string" required>
  `"OK"` on success.
</ResponseField>

***

## getblockhash

Returns the block hash at a given height.

### Request

<ParamField body="params" type="array" required>
  A single-element array containing the target block height as an integer: `[height]`.
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl -s http://127.0.0.1:18180/json_rpc \
    -H 'Content-Type: application/json' \
    -d '{
      "jsonrpc": "2.0",
      "method": "getblockhash",
      "params": [826420],
      "id": "1"
    }'
  ```

  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "method": "getblockhash",
    "params": [826420],
    "id": "1"
  }
  ```
</CodeGroup>

### Response

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "1",
  "result": "9a0158c87c062c63a675c65eda91c10bb6d7b68b854be783aa85b2cbbf3b8a55"
}
```

The result is the block hash string directly (not a nested object).

***

## getblocktemplate

Returns a block template that a miner can use to attempt proof-of-work. The template includes the current difficulty, block height, and a blob to hash.

### Request

<ParamField body="reserve_size" type="integer" required>
  Number of bytes to reserve in the block blob for the miner's extra nonce. Maximum 255 bytes.
</ParamField>

<ParamField body="wallet_address" type="string" required>
  The mining reward address where the block reward will be sent if you find a valid block.
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl -s http://127.0.0.1:18180/json_rpc \
    -H 'Content-Type: application/json' \
    -d '{
      "jsonrpc": "2.0",
      "method": "getblocktemplate",
      "params": {
        "reserve_size": 8,
        "wallet_address": "fireXfGYourMiningAddressHere..."
      },
      "id": "1"
    }'
  ```

  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "method": "getblocktemplate",
    "params": {
      "reserve_size": 8,
      "wallet_address": "fireXfGYourMiningAddressHere..."
    },
    "id": "1"
  }
  ```
</CodeGroup>

### Response

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "1",
  "result": {
    "difficulty": 12345678,
    "height": 900001,
    "reserved_offset": 130,
    "blocktemplate_blob": "0d0d...abcdef",
    "status": "OK"
  }
}
```

<ResponseField name="difficulty" type="integer" required>
  Current mining difficulty. Your hash must be numerically less than `2^256 / difficulty`.
</ResponseField>

<ResponseField name="height" type="integer" required>
  The height of the block you are attempting to mine (next block index).
</ResponseField>

<ResponseField name="reserved_offset" type="integer" required>
  Byte offset within `blocktemplate_blob` where your extra nonce data should be written.
</ResponseField>

<ResponseField name="blocktemplate_blob" type="string" required>
  Hex-encoded block template blob. Replace bytes at `reserved_offset` with your nonce, hash with the active PoW algorithm, and submit with `submitblock` if the result meets difficulty.
</ResponseField>

<ResponseField name="status" type="string" required>
  `"OK"` on success.
</ResponseField>

***

## submitblock

Submits a solved block blob to the network for validation and propagation.

### Request

<ParamField body="params" type="array" required>
  A single-element array containing the solved block blob as a hex string: `["<block_blob_hex>"]`.
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl -s http://127.0.0.1:18180/json_rpc \
    -H 'Content-Type: application/json' \
    -d '{
      "jsonrpc": "2.0",
      "method": "submitblock",
      "params": ["0d0d...solvedblob"],
      "id": "1"
    }'
  ```

  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "method": "submitblock",
    "params": ["0d0d...solvedblob"],
    "id": "1"
  }
  ```
</CodeGroup>

### Response

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "1",
  "result": {
    "status": "OK"
  }
}
```

<ResponseField name="status" type="string" required>
  `"OK"` if the block was accepted. An error response is returned if the block is invalid or does not meet the current difficulty.
</ResponseField>

***

## getlastblockheader

Returns the block header of the most recently confirmed block in the main chain. No parameters are required.

### Request

<CodeGroup>
  ```bash curl theme={null}
  curl -s http://127.0.0.1:18180/json_rpc \
    -H 'Content-Type: application/json' \
    -d '{
      "jsonrpc": "2.0",
      "method": "getlastblockheader",
      "params": {},
      "id": "1"
    }'
  ```

  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "method": "getlastblockheader",
    "params": {},
    "id": "1"
  }
  ```
</CodeGroup>

### Response

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "1",
  "result": {
    "block_header": {
      "major_version": 9,
      "minor_version": 0,
      "timestamp": 1712345678,
      "prev_hash": "b1c2d3e4f5...",
      "nonce": 1234567890,
      "orphan_status": false,
      "height": 899999,
      "depth": 0,
      "deposits": 8000000000000,
      "hash": "a1b2c3d4e5f6...",
      "difficulty": 12345678,
      "reward": 180000000
    },
    "status": "OK"
  }
}
```

<ResponseField name="block_header.major_version" type="integer" required>
  Block major version. Version 9 is the Godflame/Fuego consensus era, active from height 826420.
</ResponseField>

<ResponseField name="block_header.minor_version" type="integer" required>
  Block minor version.
</ResponseField>

<ResponseField name="block_header.timestamp" type="integer" required>
  Unix timestamp recorded in the block header by the miner.
</ResponseField>

<ResponseField name="block_header.prev_hash" type="string" required>
  Hash of the preceding block.
</ResponseField>

<ResponseField name="block_header.nonce" type="integer" required>
  Proof-of-work nonce found by the miner.
</ResponseField>

<ResponseField name="block_header.orphan_status" type="boolean" required>
  `true` if this block is on an alternative chain (orphaned), `false` if it is in the main chain.
</ResponseField>

<ResponseField name="block_header.height" type="integer" required>
  Block height (index) in the chain.
</ResponseField>

<ResponseField name="block_header.depth" type="integer" required>
  Number of blocks confirmed on top of this block. `0` means it is the tip.
</ResponseField>

<ResponseField name="block_header.deposits" type="integer" required>
  Total deposit output value included in this block, in atomic units.
</ResponseField>

<ResponseField name="block_header.hash" type="string" required>
  Hex-encoded hash of this block.
</ResponseField>

<ResponseField name="block_header.difficulty" type="integer" required>
  Difficulty at which this block was mined.
</ResponseField>

<ResponseField name="block_header.reward" type="integer" required>
  Total block reward (coinbase + fees), in atomic units.
</ResponseField>

<ResponseField name="status" type="string" required>
  `"OK"` on success.
</ResponseField>

***

## getblockheaderbyhash

Returns the block header for a block identified by its hash.

### Request

<ParamField body="hash" type="string" required>
  Hex-encoded hash of the block whose header you want to retrieve.
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl -s http://127.0.0.1:18180/json_rpc \
    -H 'Content-Type: application/json' \
    -d '{
      "jsonrpc": "2.0",
      "method": "getblockheaderbyhash",
      "params": {
        "hash": "9a0158c87c062c63a675c65eda91c10bb6d7b68b854be783aa85b2cbbf3b8a55"
      },
      "id": "1"
    }'
  ```

  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "method": "getblockheaderbyhash",
    "params": {
      "hash": "9a0158c87c062c63a675c65eda91c10bb6d7b68b854be783aa85b2cbbf3b8a55"
    },
    "id": "1"
  }
  ```
</CodeGroup>

### Response

The response follows the same `block_header` structure as `getlastblockheader`. See that method for field descriptions.

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "1",
  "result": {
    "block_header": {
      "major_version": 9,
      "minor_version": 0,
      "timestamp": 1712000000,
      "prev_hash": "c9d8e7f6...",
      "nonce": 987654321,
      "orphan_status": false,
      "height": 826420,
      "depth": 73580,
      "deposits": 16000000000000,
      "hash": "9a0158c87c062c63a675c65eda91c10bb6d7b68b854be783aa85b2cbbf3b8a55",
      "difficulty": 11000000,
      "reward": 190000000
    },
    "status": "OK"
  }
}
```

***

## getblockheaderbyheight

Returns the block header for a block at a specific chain height.

### Request

<ParamField body="height" type="integer" required>
  The block height to query. Must be less than or equal to the current chain height.
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl -s http://127.0.0.1:18180/json_rpc \
    -H 'Content-Type: application/json' \
    -d '{
      "jsonrpc": "2.0",
      "method": "getblockheaderbyheight",
      "params": {
        "height": 826420
      },
      "id": "1"
    }'
  ```

  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "method": "getblockheaderbyheight",
    "params": {
      "height": 826420
    },
    "id": "1"
  }
  ```
</CodeGroup>

### Response

The response follows the same `block_header` structure as `getlastblockheader`. See that method for field descriptions.

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "1",
  "result": {
    "block_header": {
      "major_version": 9,
      "minor_version": 0,
      "timestamp": 1712000000,
      "prev_hash": "c9d8e7f6...",
      "nonce": 987654321,
      "orphan_status": false,
      "height": 826420,
      "depth": 73580,
      "deposits": 16000000000000,
      "hash": "9a0158c87c062c63a675c65eda91c10bb6d7b68b854be783aa85b2cbbf3b8a55",
      "difficulty": 11000000,
      "reward": 190000000
    },
    "status": "OK"
  }
}
```
