0%
HomeBlogProducts
Alchemy Launches Filtered Pending Transaction Notifications

Alchemy Launches Filtered Pending Transaction Notifications

Author: Ben Godlove

Reviewed by Brady Werkheiser


Published on June 15, 20212 min read

For the first time, developers can see real-time engagements with their smart contracts and end-users can get real time updates over their transaction lifecycle.

Let’s say you are a smart contract owner and you want to see all pending transactions for your contract. Maybe you’re building out health monitoring for your contract. Maybe you’re trying to route pending notifications to your users. Regardless, it’s a big hassle to do this in the ecosystem today.

Let’s first take a look at how you would do this without Alchemy. Ethereum exposes the eth_newPendingTransactions API, which will give you a stream of pending transaction hashes. Then for each of these transaction hashes you can fetch the full transaction payload, extract the contract address, and then run your business logic if the address matches your contract.

This process gets expensive very quickly as you will be checking dozens of transactions per second, most of which are irrelevant to you, and making a network call for each one of them.

Rather than accepting a full stream of pending transaction hashes and then checking each one, Alchemy will run the check for you before streaming. You provide an address to our alchemy_pendingTransactions endpoint and we will stream you pending transactions that are going to or from the address.

Let’s see this in action. We’ll observe pending transactions for SushiSwap's router address.

Stream pending transactions for SushiSwap's router address
Stream pending transactions for SushiSwap's router address

As you can see SushiSwap is pretty active.

We're excited to see what you come up with! To get your creative juices flowing, here are some applications that are now massively easier to build:

Create an activity monitor on your smart contract. You can set up a subscription to stream pending transactions to your smart contract. If you don't receive a transaction within a given time frame, fire off an alert!

Find out when a particular address becomes "active". Maybe you want to know when someone sends ETH to a verified scam address. Or when a black hat hacker finally removes funds from a particular address.

Notify your end users when their transaction is pending. Set up a subscription from the client side when your end-user submits a transaction, and notify your user when the transaction is submitted to the mempool. Perhaps soon we won't have to keep reloading block explorers?

For other subscription capabilities as well as webhooks, check out Alchemy’s Notify offering.

Section background image

Build blockchain magic

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get your API key