0

I am trying to compare the balance of address1 which I am printing out normally with the total supply of the tokens in address 2. In order to get the total supply I have to get the ABI of the contract and check the value of the total supply function. For some reason I am unable to get the ABI of address 2 and it is not giving me any errors. The if statement at the end is just to check that one is less than the other

import pip._vendor.requests 
from requests import get


API_KEY = "UX33KV3H6CNV4KEG3J2EWG6BY9E4WRVKKG"
address = "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"
address2 = "0xe0BB0D3DE8c10976511e5030cA403dBf4c25165B"
BASE_URL = "https://api.etherscan.io/api"

def make_api_url(module, action, address , **kwargs):
    url = BASE_URL + f"?module={module}&action={action}&address={address}&apikey={API_KEY}"

    for key, value in kwargs.items():
        url+= f"&{key}={value}"

        return url

def get_account_balance(address):
    get_balance_url = make_api_url("account", "balance", address, tag="latest")
    response = get(get_balance_url)
    data = response.json()

    value = (data["result"]) 
    return value

balance = get_account_balance(address)
print(balance)


def get_abi(address2):
    get_abi_url = make_api_url("contract", "getabi", address2)
    response = get(get_abi_url)
    data = response.json()["result"]

    for tx in data:
        supply = tx["totalSupply"]
        print("Total Supply: ", supply)

# Checking L1 and L2 tokens in case L2 is more than balance of L1
    if balance >= supply : print(True)
    else : print(False)

0 Answers0