Untitled

mail@pastecode.io avatar
unknown
python
a year ago
787 B
6
Indexable
Never
from python_graphql_client import GraphqlClient
import asyncio

ws = GraphqlClient(endpoint="wss://streaming.bitquery.io/graphql")

query = """
subscription MyQueryWithVariables($network: evm_network!, $limit: Int!, $symbols: [String!]!) {
  EVM(network: $network) {
    Transfers(
      limit: {count: $limit}
      orderBy: {descending: Block_Number}
      where: {Transfer: {Currency: {Symbol: {in: $symbols}}}}
    ) {
      Block {
        Number
        Hash
      }
      Transfer {
        Currency {
          Symbol
          Name
        }
        Amount
      }
    }
  }
}
"""

variables = {
    "network": "eth",
    "limit": 2,
    "symbols": ["ETH", "USDT"]
}

asyncio.run(ws.subscribe(query=query, variables=variables, handle=print))
Leave a Comment