Getting confirmed transactions

I’m just getting started to Infura, so i’m sorry if this is a noob question. I’m trying to get transactions in real time on this contract, so basically whenever new confirmed transactions are done, i would like to get the transaction details. Unfortunately, right now i only managed to do this:

import asyncio
import websockets
import json

async def connect():
    uri = "wss://"
    async with websockets.connect(uri) as ws:
        await ws.send('{"jsonrpc":"2.0", "id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]}')
        await ws.send('{"jsonrpc":"2.0", "id": 1, "method": "eth_subscribe", "params": ["logs", {"address": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d"}]}')
        #msg = await asyncio.wait_for(ws.recv(), 4)
        while True:
            msg = await ws.recv()
            message = json.loads(msg)


which will send me all the pending transactions. Is there any way to get only confirmed ones, instead of pending? Thanks in advance!

Welcome to the Infura community, @dxy02
That’s a great question.
One way to get the confirmed transaction is to subscribe with newHeads, when a new block comes in, send eth_getBlockByHash, based on the hash provided in the newHeads event. You will need to set your show Transactions detail flag to ‘true’ in your eth_getBlockByHash request. Then the response of the eth_getBlockByHash will include a transactions object which will list all of the transactions from that block. You can then filter by the contract address.

This is great! Thank you a lot!