Withdrawal
A validator withdrawal, pushed into a block by the consensus layer since the Shanghai fork (EIP-4895).
import { Effect } from "effect";import { Eth } from "@ethect/core/rpc";
const withdrawn = Effect.gen(function* () { const block = yield* Eth.getBlockByNumber("latest", false); if (block === null) return 0n; // block.withdrawals: ReadonlyArray<Withdrawal.Withdrawal> | undefined const gwei = (block.withdrawals ?? []).reduce((sum, { amount }) => sum + amount, 0n); return gwei * 10n ** 9n; // in wei});Schemas
Section titled “Schemas”| Schema | Type | Describes | Used by |
|---|---|---|---|
Withdrawal.schema |
Withdrawal.Withdrawal |
one withdrawal | withdrawals of a Block and of a BlockOverride |
Fields
Section titled “Fields”| Field | Type | Notes |
|---|---|---|
index |
bigint |
the number of the withdrawal, counted over the whole chain |
validatorIndex |
bigint |
the validator the withdrawal comes from |
address |
Address |
the account that receives the ether |
amount |
bigint |
in gwei, not in wei |
Behavior
Section titled “Behavior”amountis in gwei. A balance and thevalueof a transaction are in wei. Multiply the amount by10n ** 9nto compare it with them.- Not a transaction. A withdrawal credits its
addresswithout a transaction, a receipt or a log. It only appears in thewithdrawalsof its block. withdrawalscan be absent. A block from before Shanghai has nowithdrawalskey. A later block with none has an empty array, as every block of a fresh anvil does.