# get\_block\_information

根据区块 ID 获取该区块基本信息。

## 方法定义

```python
def get_block_information(self, block_id: BlockIdentifier) -> Optional[BlockInformationData]
```

## 参数说明

| 参数        | 类型              | 说明                                                    |
| --------- | --------------- | ----------------------------------------------------- |
| block\_id | BlockIdentifier | 区块 ID,可以是区块号、区块哈希或 'latest','earliest','pending' 等标识符 |

## 返回值

返回 BlockInformationData 对象,包含以下字段:

| 字段            | 类型                                             | 说明         |
| ------------- | ---------------------------------------------- | ---------- |
| block\_hash   | HexBytes                                       | 区块哈希       |
| block\_number | BlockNumber                                    | 区块高度       |
| timestamp     | Timestamp                                      | 区块时间戳      |
| miner         | ChecksumAddress                                | 矿工地址       |
| gas\_used     | int                                            | 区块已使用的 Gas |
| gas\_limit    | int                                            | 区块 Gas 上限  |
| transactions  | Union\[Sequence\[HexBytes], Sequence\[TxData]] | 区块内的交易列表   |

## 示例代码

```python
# 获取最新区块信息
latest_block = chain.get_block_information("latest")
print(f"Block Number: {latest_block.block_number}")
print(f"Block Hash: {latest_block.block_hash.hex()}")
print(f"Miner: {latest_block.miner}")
print(f"Gas Used: {latest_block.gas_used}")

# 通过区块号获取
block = chain.get_block_information(12345678)

# 通过区块哈希获取
block = chain.get_block_information("0x...")
```


---

# 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://poseidon.seaeye.cn/evm/chain/get_block_information.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.
