Skip to content

Instantly share code, notes, and snippets.

@shov
Last active September 6, 2023 04:11
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save shov/94687d4ce55058cb84aeb5a5145f0871 to your computer and use it in GitHub Desktop.
Save shov/94687d4ce55058cb84aeb5a5145f0871 to your computer and use it in GitHub Desktop.
Etherscan public API to fetch transactions by wallet

Etherscan public API

Overview

There is no documentation at the moment, but there are some rumors. And experemental way I've made sure about few end-points are working good:

Common account info

GET: https://www.etherchain.org/api/account/0xAAAsomeADDR00000000000/ Will return something like that:

{
  "address": "0xAAAsomeADDR00000000000",
  "balance": "0",
  "name": null,
  "firstseen": "2018-02-13T08:25:30.000Z",
  "createdby": "d8e93673v4ghhshd7j9l61adf2b1d43742d8f8629586k6kfjmft98c112b16d6u9",
  "lastseen": "2018-02-20T10:29:08.000Z",
  "blocksmined": 0,
  "unclesmined": 0,
  "nameverified": null
}

Actions interface

But in general there is another end-point which use GET-params-quering approach:

To get balance call: GET: http://api.etherscan.io/api?module=account&action=balance&address=0xAAAsomeADDR00000000000

And you'll get:

{
  "status": "1",
  "message": "OK",
  "result": "0"
}

As we seen there are three important arguments:

  • module - it's just like controller or class or lib
  • action - action/method
  • address - here you should put a wallet

Transactions

To fetch all someone transaction history 'etherscan' offer just a one way: https://etherscan.io/address/0xAAAsomeADDR00000000000 and here you'll see web interface to comfortable read transaction list.. but if you looking for approach to fetch all them as json with your application there is one API:

GET: http://api.etherscan.io/api?module=account&action=txlist&address=0xAAAsomeADDR00000000000&sort=asc

Example of a response:

{
  "status": "1",
  "message": "OK",
  "result": [
    {
      "blockNumber": "------",
      "timeStamp": "-------",
      "hash": "0x-----",
      "nonce": "1",
      "blockHash": "0x--------",
      "transactionIndex": "70",
      "from": "0x----------",
      "to": "0x---------",
      "value": "87000",
      "gas": "636879",
      "gasPrice": "10000000000",
      "isError": "0",
      "txreceipt_status": "1",
      "input": ".. loooong value ...",
      "contractAddress": "0x--------",
      "cumulativeGasUsed": "3190544",
      "gasUsed": "636879",
      "confirmations": "-----"
    },
    ...
  ]
}

Pay attention a value gives in wei and you might convert it to eth before use it in your processes, you albe to do it by formula eth = wei / (10 * 10^17) and validate your result here for example

ฅ(≚ᄌ≚) Have a nice day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment