I'm taking my first steps with the etherscan API. My goal is to successfully export data from a wallet, mainly "Token Transfer ERC20", and to be able to calculate the wallet's ROI.
To do this, I'll need the TokenSymbol, MethodID, value (ETH) I could then classify the transactions by TokenSymbol, then sum the transactions according to MethodId and calculate the amount in ETH invested and recovered. My problem is that.
def get_ethereum_transactions(address, api_key):
url = f"https://api.etherscan.io/api?module=account&action=txlist&address={address}&apikey={api_key}"
response = requests.get(url)
data = response.json()
if data['status'] == '1':
transactions = data['result']
return transactions
else:
print(f"Erreur de l'API Etherscan : {data['message']}")
return []
Returns : blockNumber, timeStamp, hash, nonce, blockHash ,transactionIndex, from ,to, value, gas, gasPrice, isError, txreceipt_status, input, contractAddress (empty), cumulativeGasUsed, gasUsed, confirmations, methodId, functionName
I tried going to etherscan directly under the Token transfer ERC20 tab and doing a csv export. Here I am able to receive: Txhash, Blockno, UnixTimestamp, DateTime ,From, To, TokenValue, USDValueDayOfTx (returns N/A), ContractAddress, TokenName, TokenSymbol
By merging these two things via tx hash, I should be able to reconstruct a database containing Txash(key), TokenSymbol, methodId
However, I'd have to figure out how to export this CSV file directly from API?
I'm still missing the eth value of this transaction. I have the token value in the cCSV export, but it's not significant, so I can't do anything with it.
Any ideas? suggestions?
Trying to export etherscan data for a specific wallet and compute data to get ROI per Token and global wallet ROI.