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
|
|
@ -416,6 +416,16 @@ def get_token_balance(token_address, wallet_address, decimals=False):
|
|||
return round(token_balance, 15)
|
||||
else:
|
||||
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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue