Skip to content

Instantly share code, notes, and snippets.

@eshaben
Created June 24, 2022 17:19
Show Gist options
  • Save eshaben/3d0ec0ba4f1724d51d90bbe47dbe1f53 to your computer and use it in GitHub Desktop.
Save eshaben/3d0ec0ba4f1724d51d90bbe47dbe1f53 to your computer and use it in GitHub Desktop.
from eth_utils import to_checksum_address
import requests
# Insert addresses to check
addresses = []
def get_transfers(query):
res = requests.post("https://app.gc.subsquid.io/beta/moonriver-transfers/1/graphql", json={'query': query}).json()
transfers = res['data']['transfers']
return transfers
for address in addresses:
checksum_address = to_checksum_address(address)
to_query = """query {
transfers (where: {
to_eq: """ + '"' + checksum_address + '"' + """,
assetId_eq: "42259045809535163221576417993425387648"
}
) {
id
assetId
to
from
balance
status
}
}"""
from_query = """query {
transfers (where: {
from_eq: """ + '"' + checksum_address + '"' + """,
assetId_eq: "42259045809535163221576417993425387648",
}
) {
id
assetId
to
from
balance
status
}
}"""
transfers_in = get_transfers(to_query)
transfers_out = get_transfers(from_query)
inflow = 0
for transfer in transfers_in:
inflow += int(transfer['balance'])
outflow = 0
for transfer in transfers_out:
outflow += int(transfer['balance'])
if inflow != 0:
print("Address", address)
print("Inflow", inflow * 10 ** -12)
if outflow != 0:
print("Address", address)
print("Outflow", outflow * 10 ** -12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment