Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support eth_getBlockReceipts from Block #4438

Closed
ghost opened this issue Oct 25, 2023 · 3 comments
Closed

Support eth_getBlockReceipts from Block #4438

ghost opened this issue Oct 25, 2023 · 3 comments
Labels
enhancement New feature or improvement. minor-bump Planned for the next minor version bump. v6 Issues regarding v6

Comments

@ghost
Copy link

ghost commented Oct 25, 2023

Describe the Feature

About the eth_getBlockReceipts API: ethereum/execution-apis#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)
@ghost ghost added the enhancement New feature or improvement. label Oct 25, 2023
@roflganker
Copy link

roflganker commented Feb 6, 2024

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));
  }
}

@ricmoo
Copy link
Member

ricmoo commented Feb 6, 2024

I do think this makes sense to add. It’s a feature I wanted, but didn’t realize there was an RPC for it. :)

@ricmoo ricmoo added on-deck This Enhancement or Bug is currently being worked on. minor-bump Planned for the next minor version bump. v6 Issues regarding v6 next-patch Issues scheduled for the next arch release. and removed next-patch Issues scheduled for the next arch release. labels Feb 6, 2024
@ghost ghost closed this as completed Feb 26, 2024
@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Jun 3, 2024
@ricmoo
Copy link
Member

ricmoo commented Jun 3, 2024

Why was this closed? Is it not a widely adopted RPC call?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. minor-bump Planned for the next minor version bump. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants