Initial goal: catch transactions from address (when address calls "swap" events or "addliquidity" events, or does transfer on PancakeSwap router). I want to catch that kind of transactions and get data about them as soon as they appear, before they are writen to block.

Nethereum had some kind of code for pending transactions:

using Nethereum.JsonRpc.WebSocketStreamingClient;
using Nethereum.RPC.Reactive.Eth.Subscriptions;
using Nethereum.Web3;
using Nethereum.Web3.Accounts;

using System;
using System.Threading.Tasks;

class Program
    static async Task Main()
        await NewPendingTransactions();

    public static async Task NewPendingTransactions()
        Account account = new Account("PRIVATE_KEY", 56);
        Web3 web3 = new Web3(account, "https://bsc-mainnet.core.chainstack.com/API_KEY");

        using (var client = new StreamingWebSocketClient("wss://bsc-mainnet.core.chainstack.com/ws/API_KEY"))
            // create the subscription
            // it won't start receiving data until Subscribe is called on it
            var subscription = new EthNewPendingTransactionObservableSubscription(client);

            // attach a handler subscription created event (optional)
            // this will only occur once when Subscribe has been called
            subscription.GetSubscribeResponseAsObservable().Subscribe(subscriptionId =>
                Console.WriteLine("Pending transactions subscription Id: " + subscriptionId));

            subscription.GetSubscriptionDataResponsesAsObservable().Subscribe(async transactionHash =>
                // Get the pending transaction with proof asynchronously
                var transactionWithProof = await web3.Eth.Transactions.GetTransactionByHash.SendRequestAsync(transactionHash);

                if (transactionWithProof == null)

This code does it's job, but it calls GetTransactionByHash.SendRequestAsync for EVERY new pending transaction, which means that it drains my RPC rate limits extremely fast.

Is there a better way to achieve this? Maybe there is a way how to make transaction come from an event already in a way that I can decode it (so that it comes not as hash, but as object which can be decoded). Or maybe it is better to make something like an event listener, so it would filter out "from" and "to" fields?

Could someone please give a helping hand for this?...

1 Answer 1


Unfortunately, there is no way to somehow "not call" an RPC for each transaction hash that comes through socket. So, if you want to catch all pending transactions and check their contents, you will HAVE to call RPC for each hash. Local full node might help here, not to call other API's, but local node requires exceptionally strong PC.

I just bought subscription with 50+ million requests on chainstack + added load balancing in code for public free nodes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.