I am a beginner and need help with converting str to float on python.
the code seems to work fine locally, but when I deploy on heroku I get
"ValueError: could not convert string to float".
Is anybody else experiencing this? It would be great if you could help me.
2022-01-26T14:40:03.536858+00:00 app[web.1]:
tx_count = float(raw_data["result"].replace("0x", ""))
2022-01-26T14:40:03.536858+00:00 app[web.1]:
#ValueError: could not convert string to float: 'Invalid API Key'
my code:
my_address = request.form["public_key"]
response = requests.get(f"https://api.etherscan.io/api?module=proxy&action=eth_getTransactionCount&address={my_address}&tag=latest&apikey={API_KEY}")
raw_data = response.json()
raw_data:
raw_data = {
'jsonrpc': '2.0',
'id': 1,
'result': '0x3'
}
I want raw_data["result"]
to be a number because I want to use the number to calculate.
I created a repository on github https://github.com/yataishiba/co2-calc-eth
UPDATE I tried this but it is still not working... Convert hex string to int in Python