> 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).

# Block Environment

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`.

In MegaETH specs (MiniRex and above), accessing block environment fields triggers [gas detention](https://github.com/megaeth-labs/mega-evm/blob/main/docs/spec/evm/gas-detention.md) — the remaining compute gas is capped to reduce parallel execution conflicts. 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
