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.
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
Section titled “Schemas”| Schema | Type | Describes | Returned by |
|---|---|---|---|
MinedBlock.schema |
MinedBlock.MinedBlock |
a mined block whose transactions carry their output and revertReason |
Anvil.mineDetailed, Evm.mineDetailed |
Both methods return an array, one MinedBlock per block mined.
Fields
Section titled “Fields”A MinedBlock has every field of a Block.Full: the header, the
body and transactions in full. Each transaction is a
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
Section titled “Behavior”outputof 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 sendsoutput: "0xdeadbeef"andrevertReason: "custom error 0xdeadbeef". - No
revertReasonon success. The key is absent, notnull: test it withtransaction.revertReason !== undefined. - Still a union.
transaction.typetells the transaction types apart as inTransaction, and narrows the fees and the other fields a type has. - The status is in the receipt. A
MinedBlockdoes not say"success"or"reverted": readEth.getTransactionReceiptfor that.