How Pending Transaction WebSockets Subscription Work
When using the alchemy_pendingTransactions
method to listen for pending transactions, it’s important to understand which transactions will be captured.
Will I Only Receive Pending Transactions Sent Through Alchemy?
Yes, when you set up a WebSocket using alchemy_pendingTransactions
, you will only receive pending transactions that are sent through Alchemy’s nodes. This is because pending transactions exist in the mempool of individual nodes, and Alchemy can only monitor and capture the transactions that pass through its own infrastructure.
Why Is This the Case?
Pending transactions are stored in the mempool of each node individually, and there’s no global access to mempools across all nodes in the network. Therefore, it’s impossible for any provider, including Alchemy, to capture all pending transactions across every node’s mempool on the global blockchain network.
What About Mined Transactions?
Once a pending transaction is mined and added to a block, it becomes part of the canonical chain. At that point, all nodes, including Alchemy, will eventually recognize and store that transaction. Therefore, mined transactions are visible across all nodes, regardless of which node originally saw the pending transaction.
By using alchemy_pendingTransactions
, you’ll receive pending transactions passing through Alchemy’s nodes. However, for a complete picture, once these transactions are mined, they will be visible across the entire blockchain network!
📘 For more details on how the Subscription API works with pending transactions, visit our documentation.