[Python] Grab transfer details in TRONSCAN

Discussão em 'Python' iniciado por Stack, Março 12, 2025.

  1. Stack

    Stack Membro Participativo

    I tried to write a Python code to grab all TRC20 transactions for a specific address. I referred to the tronscan documentation, but the final outcome was No TRC20 transfers found for address Txxxxxxxxxxxxxxx for any address I put. Please help me solve this problem. Thank you so much.

    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}.")


    I just want to grab all transactions first and connect to MySQL for the telegram bot in the next step.

    Continue reading...

Compartilhe esta Página