Example transaction: https://etherscan.io/tx/0x2edfb0bf11355a48bbb93c567a8c6de39f80de515ceb8b26dbcbf4729bd8a217

In code given a transaction object, how would I fetch the price of ETH at the time of the transaction?

Using the example transaction, it's sending 4.1 ETH, at an estimate value of $4253.18. How did it know that the price of ETH was $1037 at the time?


Etherscan most likely uses APIs from different exchanges to retrieve the price of Ether. So basically exchanges offer public access to query for the price of an asset. Either the exchanges provide also historical data or Etherscan stores the prices internally for history.

You can see one exchange's API for example here: https://www.kraken.com/features/api

I don't know which exchanges provide also historical data and which APIs Etherscan uses but in the end it doesn't make much difference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.