I'm looking for some way to listen to transactions happening on this address. Basically, whenever a new transaction is confirmed, i would like to receive it. How can i do that? I just got started to web3 and Infura so i don't really know where to go from here.

I tried the Infura websocket, with very little results:

import asyncio
import websockets

async def connect():
    uri = "wss://mainnet.infura.io/ws/v3/<MY-PROJECT>"
    async with websockets.connect(uri) as ws:
        await ws.send('{"jsonrpc":"2.0", "id": 1, "method": "eth_subscribe", "params": ["logs", {"address": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d"}]}')

        while True:
            msg = await ws.recv()
            message = json.loads(msg)


This should subscribe to all the events happening on the smart contract, but i'm receiving nothing. Any kind of help is appreciated



Your Answer

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

Browse other questions tagged or ask your own question.