So one thing i tried and worked for me is the following:
i hit two endpoints:
trc20url = f"https://api.trongrid.io/v1/accounts/{address}/transactions/trc20?&contract_address={contract_add}&min_timestamp={getminTime}&max_timestamp={maxTime}"
trxurl = f"https://api.trongrid.io/v1/accounts/{address}/transactions"
for the trc20 endpoint check this: https://stackoverflow.com/a/72162936/17474386
now for the trx or trc10 also:
what i did i called the get request as follows:
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
trxresponse = requests.get(trxurl, headers = headers)
trxdicResponse = trxresponse.json()
i then looped over the result:
for tx in trxdicResponse['data']:
if (tx["raw_data"]["contract"][0]['type']) ==
'TransferContract':
# this means this is a trx tx , (transferAssetContract for trc10, and triggersmartcontract for trc20)
from there you can build a list of the txs and do whatever you want, also if you want this process to be automated, you can do the following:
trxblock = client.get_block()
lastBlockNum = trxblock['block_header']['raw_data']['number']
maxTime = trxblock['block_header']['raw_data']['timestamp']
getuserBlock = get from DB
getfirstBlock = getuserBlock.trxLastBlock
getminTime = client.get_block(getfirstBlock)['block_header']['raw_data']['timestamp']
so what you do is you get the latest block and get its timestamp, then get the last block you looped over from your DB and get its timestamp and then you just feed them to the request parameters , then update the last scanned block in your DB then repeat.