1

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)
        print(message)

asyncio.get_event_loop().run_until_complete(connect())

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

Jack022
  • 135
  • 4
  • There is a question with some useful javascript snippets https://ethereum.stackexchange.com/questions/2531/common-useful-javascript-snippets-for-geth. It should be an easy exercise to write them in python. – Ismael Feb 16 '21 at 18:32

0 Answers0