# 【Block】

`block` 顧名思義就是區塊鏈的訊息，可以藉由調用下列函數來知道一些資訊。

* `block.basefee (uint)`: 當前區塊的基本費用 ([EIP-3198](https://eips.ethereum.org/EIPS/eip-3198) and [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559))
* `block.chainid (uint)`: 當前的 chain id
* `block.coinbase (address payable)`: 當前區塊礦工地址
* `block.difficulty (uint)`: 當前區塊難度
* `block.gaslimit (uint)`: 當前區塊的 gas limit
* `block.number (uint)`: 當前區塊編號
* `block.timestamp (uint)`: 當前區塊的 timestamp，使用 UNIX 時間秒

官方強烈建議不要依賴 `block.timestamp` 來做為隨機數的種子，除非我們真的知道他要用來做什麼。

`block.timestamp` 可以被礦工有意無意的影響，壞礦工可能會使用特定的散列上運行賭場支付函數（casino payout function on a chosen hash），並進入不同的 hash 值當他們沒有獲得任何金錢報酬。

當前的 `block.timestamp` 必須「嚴格大於」前一個區塊，但唯一的保證是這個區塊會在兩個執行區塊的 timestamps 之間。不一定代表正確的時間，只是兩者之間的某處。

在 version 0.7.0, `now` 被移除了，現在我們必須只能使用 `block.timestamp`

注意謹慎使用 `block.timestamp` 和 `blockhash`，因爲他們都是有可能被篡改的。


---

# 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://chihaolu.gitbook.io/all-in-one-solidity/part-i-basic/chapter-7-jue-se-he-quan-ju-xun-xi-global-variables/block.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.
