Eth.getBlockReceipts
Returns the receipts of every transaction in a block, in the order of the block, or null
when the node does not have the block.
import { Effect } from "effect";import { FetchHttpClient } from "effect/http";import { Transport } from "@ethect/core";import { Eth } from "@ethect/core/rpc";
const receipts = await Eth.getBlockReceipts("latest").pipe( Effect.provide(Transport.http("http://127.0.0.1:8545")), Effect.provide(FetchHttpClient.layer), Effect.runPromise,);// receipts?.map((receipt) => receipt.status): ["success", "success", "reverted"]The call works over every transport. The examples below leave the transport out.
Find what reverted
Section titled “Find what reverted”One request gives the outcome of the whole block.
import { Effect } from "effect";import { Eth } from "@ethect/core/rpc";
const reverted = Effect.gen(function* () { const receipts = yield* Eth.getBlockReceipts("latest"); if (receipts === null) return []; return receipts .filter((receipt) => receipt.status === "reverted") .map((receipt) => receipt.transactionHash);});Every log of a block
Section titled “Every log of a block”Each receipt carries the logs its transaction emitted.
import { Effect } from "effect";import { Eth } from "@ethect/core/rpc";
const logs = Effect.gen(function* () { const receipts = yield* Eth.getBlockReceipts(19_000_000n); if (receipts === null) return []; return receipts.flatMap((receipt) => receipt.logs);});By block hash
Section titled “By block hash”Name the block by its hash to read the receipts of that exact block.
import { Effect } from "effect";import { Eth } from "@ethect/core/rpc";
const receipts = Eth.getBlockReceipts({ blockHash: "0xe5178f52e018186949d9fe9168c6011820f9c6bd449a93dbb07c09dfc0af3dfa",});Returns
Section titled “Returns”Effect<ReadonlyArray<Receipt.Receipt> | null, Method.Error, Transport>
One Receipt per transaction, or null when the node does not
have the block.
Parameters
Section titled “Parameters”- Type:
BlockId.BlockId
The block: a number, a tag, or an object that names the block by number or by hash. It is required.
import { Effect } from "effect";import { Eth } from "@ethect/core/rpc";
const receipts = Effect.all([ Eth.getBlockReceipts("finalized"), Eth.getBlockReceipts(19_000_000n), Eth.getBlockReceipts({ blockHash: `0x${"ab".repeat(32)}` }),]);Behavior
Section titled “Behavior”null, not an error. A number above the head and a hash no block has both givenull.- An empty block gives
[]. The block exists and has no transaction. - In the order of the block. The receipt at position
ihastransactionIndexequal toi. - One request for the block. It replaces one
Eth.getTransactionReceiptper transaction.
Errors
Section titled “Errors”The three errors every method can fail with. The case specific to this method:
| Error | Reason | When |
|---|---|---|
CodecError |
on: "params" |
the block number is negative: nothing is sent |
JSON-RPC method
Section titled “JSON-RPC method”eth_getBlockReceipts