Übertragungsdetails in Tronscan schnappen
Posted: 12 Mar 2025, 01:54
Ich habe versucht, einen Python -Code zu schreiben, um alle TRC20 -Transaktionen für eine bestimmte Adresse zu erzielen. Ich habe auf die Tronscan -Dokumentation verwiesen, aber das Endergebnis war keine TRC20 -Übertragungen für die Adresse TXXXXXXXXXXXXXXX für jede von mir angegebene Adresse. Bitte helfen Sie mir, dieses Problem zu lösen. Vielen Dank.
Ich möchte nur zuerst alle Transaktionen abrufen und im nächsten Schritt eine Verbindung zu MySQL für den Telegrammbot herstellen.
Code: Select all
import requests
def get_trc20_transfers(tron_address, api_key):
base_url = "https://apilist.tronscan.org/api"
endpoint = f"/token_trc20/transfers"
params = {
"address": tron_address,
"limit": 20, # You can adjust the limit as needed
"start": 0, # You can adjust the start index as needed
"api_key": api_key, # Include your Tronscan API key here
}
try:
response = requests.get(base_url + endpoint, params=params)
if response.status_code == 200:
data = response.json()
transfers = data.get("data")
return transfers
else:
print(f"Failed to fetch TRC20 transfers. Status code: {response.status_code}")
return None
except requests.exceptions.RequestException as e:
print("Error:", e)
return None
if __name__ == "__main__":
tron_address = "TXxxxxxxxxxxxxxxxxxxxx" # Replace with the TRON address you want to query
tronscan_api_key = "xxxxxxxxxxxxx" # Replace with your Tronscan API key
trc20_transfers = get_trc20_transfers(tron_address, tronscan_api_key)
if trc20_transfers:
print("TRC20 Transfers:")
for transfer in trc20_transfers:
print(transfer)
else:
print(f"No TRC20 transfers found for address {tron_address}.")