Skip to content

add rpc function to fetch transactions by hashes #202

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

Merged

Conversation

iuwqyir
Copy link
Collaborator

@iuwqyir iuwqyir commented May 19, 2025

TL;DR

Added support for fetching transactions by hash through the RPC client.

What changed?

  • Added a new RawTransaction type alias in the common package
  • Generalized the RPCFetchBatch function to RPCFetchSingleBatch to work with any key type, not just block numbers
  • Added GetTransactionParams function to support transaction hash parameters
  • Implemented GetTransactions method in the RPC client to fetch transactions by hash
  • Added SerializeTransactions function to convert raw transaction data to the internal format
  • Added Close method to the IRPCClient interface and updated the mock accordingly

How to test?

  1. Fetch transactions using the new method:
client := rpc.NewClient(...)
transactions := client.GetTransactions([]string{"0x123...", "0x456..."})
  1. Verify that transaction data is properly serialized and contains the expected fields
  2. Test with both valid and invalid transaction hashes to ensure error handling works correctly

Why make this change?

This change enables direct fetching of transactions by hash, which is useful for scenarios where we need to retrieve specific transactions without fetching entire blocks. This improves efficiency when only transaction data is needed and the containing block is not relevant.

Copy link
Collaborator Author

iuwqyir commented May 19, 2025

@iuwqyir iuwqyir requested a review from catalyst17 May 19, 2025 10:53
@iuwqyir iuwqyir marked this pull request as ready for review May 19, 2025 10:53
@iuwqyir iuwqyir force-pushed the 05-19-add_rpc_function_to_fetch_transactions_by_hashes branch from 972a505 to 275e955 Compare May 19, 2025 12:12
@iuwqyir iuwqyir force-pushed the 05-19-add_rpc_function_to_fetch_transactions_by_hashes branch from 275e955 to 54a6fcd Compare May 19, 2025 12:19
@iuwqyir iuwqyir merged commit 6a6a1f3 into main May 21, 2025
5 checks passed
@iuwqyir iuwqyir deleted the 05-19-add_rpc_function_to_fetch_transactions_by_hashes branch May 21, 2025 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants