0

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Odelf
  • 1

1 Answers1

0

You have to convert the value, the value is in Wei. Convert Wei to eth. I use ETHER_VALUE 10*18

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 22 '23 at 17:11