Support eth_getBlockReceipts from Block
Describe the Feature
About the eth_getBlockReceipts API: https://github.com/ethereum/execution-apis/issues/393
Would be great if the Block object could also contain transactionReceipts fetched by the eth_getBlockReceipts call just like the block.prefetchedTransactions() method https://docs.ethers.org/v6/api/providers/#Block-prefetchedTransactions.
Something like provider.getBlock(blockHashOrBlockTag: BlockTag, prefetchTxs?: boolean, prefetchReceipts?: boolean) or provider.getBlockReceipts would be a good idea to extend existing method.
( It could speed up fetching multiple transaction receipts on the same block and will benefit for some transaction hoarders or explorers, indexers )
Code Example
provider.getBlock(blockHashOrBlockTag: BlockTag, prefetchTxs?: boolean, prefetchReceipts?: boolean)
provider.getBlockReceipts(blockHashOrBlockTag: BlockTag)
Well, here is my workaround on it for ethers v6
import { BlockTag, ethers, JsonRpcProvider, resolveProperties, TransactionReceipt, TransactionReceiptParams } from 'ethers';
export class BatchJsonRpcProvider extends JsonRpcProvider {
async getBlockReceipts(block: ethers.BlockTag): Promise<TransactionReceipt[]> {
// Source: https://docs.chainstack.com/reference/ethereum-getblockreceipts#eth_getblockreceipts-code-examples
const receipts: TransactionReceiptParams[] = await this.send('eth_getBlockReceipts', [block]);
// Source: https://github.com/ethers-io/ethers.js/blob/main/src.ts/providers/abstract-provider.ts#L1124
const network = await resolveProperties(this.getNetwork());
return receipts.map(receipt => this._wrapTransactionReceipt(receipt, network));
}
}
I do think this makes sense to add. It’s a feature I wanted, but didn’t realize there was an RPC for it. :)
Why was this closed? Is it not a widely adopted RPC call?