Subscribe to pending transactions
This tutorial shows you how to use Ethereum subscriptions to listen for new transactions on the blockchain as they get submitted.
The tutorial uses the Python websockets
library and Infura’s WebSocket endpoint to subscribe to transactions and events on the blockchain.
Prerequisites
- An Ethereum project on Infura
- Python installed
Steps
1. Create your project directory
Create a new directory:
mkdir subscribe
cd
into the directory:
cd subscribe
2. Install dependencies
Install web3.py
and the websockets
library:
pip install web3 websockets