> For the complete documentation index, see [llms.txt](https://docs.megaeth.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.megaeth.com/mega-evme/configuration/block-environment.md). Agents can also search and read this documentation through its [MCP server](https://docs.megaeth.com/~gitbook/mcp).

# Block Environment

Configure block number, timestamp, coinbase, base fee, and other block-level fields.

These options configure the block context for EVM execution. They are available in the `run` and `tx` commands. The `replay` command fetches block environment from the RPC automatically.

## Options

| Flag                          | Default       | Aliases                            | Description                          |
| ----------------------------- | ------------- | ---------------------------------- | ------------------------------------ |
| `--block.number <NUM>`        | `1`           | —                                  | Block number                         |
| `--block.coinbase <ADDR>`     | `0x0…0`       | `--block.beneficiary`              | Block coinbase / beneficiary address |
| `--block.timestamp <TS>`      | `1`           | —                                  | Block timestamp (Unix seconds)       |
| `--block.gaslimit <GAS>`      | `10000000000` | `--block.gas-limit`, `--block.gas` | Block gas limit                      |
| `--block.basefee <FEE>`       | `0`           | `--block.base-fee`                 | EIP-1559 base fee                    |
| `--block.difficulty <DIFF>`   | `0`           | —                                  | Block difficulty                     |
| `--block.prevrandao <HASH>`   | `0x0…0`       | `--block.random`                   | Previous randao value (post-merge)   |
| `--block.blobexcessgas <GAS>` | `0`           | `--block.blob-excess-gas`          | EIP-4844 blob excess gas             |

## Examples

```bash
# Simulate a specific block context — call WETH.name() at a fixed block
mega-evme tx \
  --receiver 0x4200000000000000000000000000000000000006 \
  --input 0x06fdde03 \
  --sender.balance 1ether \
  --block.number 1000 \
  --block.timestamp 1234567890 \
  --block.basefee 1000000000 \
  --basefee 1000000000

# Test COINBASE opcode — pushes the beneficiary address onto the stack
mega-evme run 0x41 --block.coinbase 0x1111111111111111111111111111111111111111
```

## Notes

The block environment affects opcodes like `NUMBER`, `TIMESTAMP`, `COINBASE`, `BASEFEE`, `DIFFICULTY` / `PREVRANDAO`, and `BLOBBASEFEE`.

From the MiniRex behavior onward, accessing block environment fields triggers [gas detention](https://github.com/megaeth-labs/mega-evm/tree/main/docs/spec/evm/gas-detention.md) — the remaining compute gas is capped to reduce parallel execution conflicts. The alias spec `MiniRex1` executes `Equivalence` behavior, where this does not apply. This is normal MegaETH behavior and is reflected in `mega-evme` execution.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.megaeth.com/mega-evme/configuration/block-environment.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
