add get_token_supply
This commit is contained in:
parent
0913ad0d15
commit
17fa53256b
1 changed files with 10 additions and 0 deletions
10
core.py
10
core.py
|
|
@ -418,6 +418,16 @@ def get_token_balance(token_address, wallet_address, decimals=False):
|
||||||
return float(round(from_token_decimals(token_balance, token_info['decimals']), 15))
|
return float(round(from_token_decimals(token_balance, token_info['decimals']), 15))
|
||||||
|
|
||||||
|
|
||||||
|
def get_token_supply(token_address, decimals=False):
|
||||||
|
token_contract = load_contract(token_address)
|
||||||
|
token_info = get_token_info(token_address)
|
||||||
|
token_supply = token_contract.functions.totalSupply().call()
|
||||||
|
if decimals:
|
||||||
|
return round(token_supply, 15)
|
||||||
|
else:
|
||||||
|
return float(round(from_token_decimals(token_supply, token_info['decimals']), 15))
|
||||||
|
|
||||||
|
|
||||||
def get_token_info(token_address, attempts=18):
|
def get_token_info(token_address, attempts=18):
|
||||||
os.makedirs(token_folder := "./data/tokens".format(token_address), exist_ok=True)
|
os.makedirs(token_folder := "./data/tokens".format(token_address), exist_ok=True)
|
||||||
token_info_file = "{}/{}.json".format(token_folder, token_address)
|
token_info_file = "{}/{}.json".format(token_folder, token_address)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue