Beispiel #1
0
def stream_eosio(client):
    operation = '''
      subscription {
        searchTransactionsForward(query:"receiver:eosio.token action:transfer") {
          undo cursor
          trace { id matchingActions { json } }
        }
      }
    '''

    dfuse_graphql = client('mainnet.eos.dfuse.io:443')
    stream = dfuse_graphql.Execute(Request(query=operation))

    print("EOS Transfers")
    for rawResult in stream:
        if rawResult.errors:
            print("An error occurred")
            print(rawResult.errors)
        else:
            result = json.loads(rawResult.data)
            for action in result['searchTransactionsForward']['trace'][
                    'matchingActions']:
                undo = result['searchTransactionsForward']['undo']
                data = action['json']
                print("Transfer %s -> %s [%s]%s" %
                      (data['from'], data['to'], data['quantity'],
                       " REVERTED" if undo else ""))
Beispiel #2
0
def stream_ethereum(client):
    # The client can be re-used for all requests, cache it at the appropriate level
    stream = client.Execute(Request(query=OPERATION_ETH))

    for rawResult in stream:
        if rawResult.errors:
            print("An error occurred")
            print(rawResult.errors)
        else:
            result = json.loads(rawResult.data)
            for call in result['searchTransactions']['node']['matchingCalls']:
                undo = result['searchTransactions']['undo']
                print("Transfer %s -> %s [%s Ether]%s" %
                      (call['from'], call['to'], call['value'],
                       " REVERTED" if undo else ""))
Beispiel #3
0
def stream_ethereum(client):
    # The client can be re-used for all requests, cache it at the appropriate level
    stream = client.Execute(
        Request(query=OPERATION_ETH,
                variables=json.dumps({
                    "addresses":
                    ["0x7a250d5630b4cf539739df2c5dacb4c659f2488d"],
                    "fields": ["FROM", "ERC20_FROM"],
                })))

    for rawResult in stream:
        if rawResult.errors:
            print("An error occurred")
            print(rawResult.errors)
        else:
            result = json.loads(rawResult.data)
            print(result)
Beispiel #4
0
def stream_eosio():
    # The client can be re-used for all requests, cache it at the appropriate level
    client = create_client('testnet.eos.dfuse.io:443')
    stream = client.Execute(Request(query=OPERATION_EOS))

    for rawResult in stream:
        if rawResult.errors:
            print("An error occurred")
            print(rawResult.errors)
        else:
            result = json.loads(rawResult.data)
            for action in result['searchTransactionsForward']['trace'][
                    'matchingActions']:
                undo = result['searchTransactionsForward']['undo']
                data = action['json']
                print("Transfer %s -> %s [%s]%s" %
                      (data['from'], data['to'], data['quantity'],
                       " REVERTED" if undo else ""))
Beispiel #5
0
def stream_ethereum(client):
    query = """
    subscription {
      searchTransactions(query: "-value:0 type:call", lowBlockNum: -1) {
         undo cursor
         node { hash matchingCalls { caller address value(encoding:ETHER) } }
       }
    }
    """
    dfuse_graphql = client('mainnet.eth.dfuse.io:443')
    stream = dfuse_graphql.Execute(Request(query=query))

    print("ETH Results")
    for rawResult in stream:
        if rawResult.errors:
            print("An error occurred")
            print(rawResult.errors)
        else:
            result = json.loads(rawResult.data)
            for call in result['searchTransactions']['node']['matchingCalls']:
                undo = result['searchTransactions']['undo']
                print("Transfer %s -> %s [%s Ether]%s" %
                      (call['caller'], call['address'], call['value'],
                       " REVERTED" if undo else ""))
Beispiel #6
0
            grpc.ssl_channel_credentials(), credentials))
    return graphql_pb2_grpc.GraphQLStub(channel)


query = '''
subscription {
  searchTransactionsForward(query: "account:eosio.token receiver:eosio.token action:transfer", limit: 10) {
    trace {
      id
      matchingActions{
        account
        receiver
        name
        json
      }
    }
  }
}
'''

dfuse_graphql = stub()
stream = dfuse_graphql.Execute(Request(query=query))

for rawResult in stream:
    if rawResult.errors:
        print("An error occurred")
        print(rawResult.errors)
    else:
        result = json.loads(rawResult.data)
        print(result['searchTransactionsForward']['trace']['matchingActions'])
Beispiel #7
0
  searchTransactionsForward(query: "action:onblock", limit: 6) {
    trace {
      id
      block {
        num
        timestamp
      }
      matchingActions{
        account
        receiver
        name
        json
      }
    }
  }
}
"""

client = create_client()
stream = client.Execute(Request(query=query))

for rawResult in stream:
    if rawResult.errors:
        print("An error occurred")
        print(rawResult.errors)
    else:
        result = json.loads(rawResult.data)
        trace = result["searchTransactionsForward"]["trace"]
        block = trace["block"]
        print(block)