# MinedBlock

A block as a test node returns it right after mining it: the block in full, each transaction
with the data its execution returned and why it reverted.

```ts
import { Effect } from "effect";
import { Anvil, Eth } from "@ethect/core/rpc";

const outcomes = Effect.gen(function* () {
  const [from, to] = yield* Eth.accounts();
  yield* Anvil.setAutomine(false);
  yield* Eth.sendTransaction({ from, to, value: 1n });
  const [block] = yield* Anvil.mineDetailed();
  // block: MinedBlock.MinedBlock
  return block?.transactions.map((transaction) => ({
    output: transaction.output, // "0x"
    reverted: transaction.revertReason !== undefined, // false
  }));
});
```

## Schemas

| Schema | Type | Describes | Returned by |
| --- | --- | --- | --- |
| `MinedBlock.schema` | `MinedBlock.MinedBlock` | a mined block whose transactions carry their `output` and `revertReason` | [`Anvil.mineDetailed`](https://ethect.dev/rpc/anvil/mining/#minedetailed), [`Evm.mineDetailed`](https://ethect.dev/rpc/evm/#minedetailed) |

Both methods return an array, one `MinedBlock` per block mined.

## Fields

A `MinedBlock` has every field of a [`Block.Full`](https://ethect.dev/rpc/types/block/): the header, the
body and `transactions` in full. Each transaction is a
[`Transaction`](https://ethect.dev/rpc/types/transaction/) of any type, with two more fields.

| Field | Type | Notes |
| --- | --- | --- |
| `transactions` | `ReadonlyArray<Transaction & { output?, revertReason? }>` | in the order of the block |
| `transactions[].output` | `Hex` (optional) | the data the execution returned: the return data, or the revert data |
| `transactions[].revertReason` | `string` (optional) | why the transaction reverted, as anvil decodes it |

## Behavior

- **`output` of a transfer is `"0x"`.** A transaction that ran no code returned nothing.
- **A revert has both.** For a transaction that reverted with the data `0xdeadbeef`, anvil 1.9
  sends `output: "0xdeadbeef"` and `revertReason: "custom error 0xdeadbeef"`.
- **No `revertReason` on success.** The key is absent, not `null`: test it with
  `transaction.revertReason !== undefined`.
- **Still a union.** `transaction.type` tells the transaction types apart as in
  [`Transaction`](https://ethect.dev/rpc/types/transaction/), and narrows the fees and the other fields a
  type has.
- **The status is in the receipt.** A `MinedBlock` does not say `"success"` or `"reverted"`:
  read [`Eth.getTransactionReceipt`](https://ethect.dev/rpc/eth/get-transaction-receipt/) for that.
