How to get Ethereum transaction list by address
Asked Answered
M

4

21

I'm looking for a way to get a list of transactions for a given address. If there are too many transactions I'd expect to be able to page the results. It would be better if I can give the latest processed transaction as parameter so I could get the latest transactions from a given point.

Something like this:

var page = 1;
txList = getTransactionList("0x323432432...", page, lastProcessedTx);
Mandell answered 29/3, 2016 at 17:28 Comment(0)
M
17

From my research so far there is no way to get transaction list for an address. You should check all the transactions in the blockchain for the given address or relate addresses to transaction hashes in a database. See this thread that confirms the lack of the needed API: https://github.com/ethereum/go-ethereum/issues/1897

An alternative to this is to use Etherscan API: https://etherscan.io/apis But it depends on a third party server.

Mandell answered 29/3, 2016 at 19:53 Comment(3)
Etherscan API only for 10000 recordsDan
@TangMonk They have a pagination feature so I guess we could retrieve all the transactions of an address.Acquirement
Using Etherscan's APIs produces an incomplete list as discussed here: tjayrush.medium.com/how-accurate-is-etherscan-83dab12eeedd. Note: I wrote TrueBlocks which is compared in this blog post.Fatshan
T
8

Probably your best bet right now is to use https://www.covalenthq.com/docs/api/

As far as I know it is free to use with no rate limiting. In your case example API request would look as follows:

curl -X GET "https://api.covalenthq.com/v1/1/address/0x5a6d3b6bf795a3160dc7c139dee9f60ce0f00cae/transactions_v2/?&key=[YOUR_API_KEY]" \
 -H "Accept: application/json"

https://www.covalenthq.com/docs/api/#get-/v1/{chain_id}/address/{address}/transfers_v2/

Tragus answered 16/9, 2021 at 20:2 Comment(2)
From March 01, 2023, they will restrict free users to a limit of 100,000 API credits per month. see hereErlking
Covalent's APIs produce an incomplete list, as discussed here. medium.com/coinmonks/…. Note: I wrote TrueBlocks which is compared in this blog post.Fatshan
H
6

Known Ethereum nodes lack functionality to get transaction list for ETH address (account).

To solve the issue, there is free and open source third-party solution — Ethereum transaction Indexer: https://github.com/Adamant-im/ETH-transactions-storage

The Indexer allows to explore transactions by Ethereum address and obtain a history of any user|wallet in just a move, like Etherscan does. Indexer is written in Python. It works as a service in background:

  • connects to Ethereum node (works well with geth or parity, others are not tested)
  • stores all transactions in Postgres database (including smart contract transactions)
  • provides data for API to get transactions by address

Indexer connects to Ethereum node and fetches transactions using JSON RPC, creating transactions Index in Postgres database. First Indexer will store transactions starting from block you indicate. After that, it will check for new blocks every 20 seconds and update the index. You may change the interval.

API for Ethereum transaction Indexer is published by Postgrest tool. If you need to provide public API, use any webserver like nginx and setup proxy to Postgrest port in config.

After index is created, you can use requests like

curl -k -X GET "http://localhost:3000/?and=(contract_to.eq.,or(txfrom.eq.0x6b924750e56a674a2ad01fbf09c7c9012f16f094,txto.eq.0x6b924750e56a674a2ad01fbf09c7c9012f16f094))&order=time.desc&limit=25"

or

https://yourserver.com/ethtxs?and=(contract_to.eq.,or(txfrom.eq.0x6b924750e56a674a2ad01fbf09c7c9012f16f094,txto.eq.0x6b924750e56a674a2ad01fbf09c7c9012f16f094))&order=time.desc&limit=25

The request will show 25 last transactions for Ethereum address 0x6b924750e56a674a2ad01fbf09c7c9012f16f094, ordered by timestamp.

Haynes answered 14/12, 2019 at 13:22 Comment(0)
R
-5

Fortunately, Geth EVM has new tools to get this done. It's possible to use debug_traceTransaction with RPC API.

In NodeJS:

var web3 = require('web3').web3;
web3.currentProvider.sendAsync({
    method: "debug_traceTransaction",
    params: ['0x3fac854179691e377fc1aa180b71a4033b6bb3bde2a7ef00bc8e78f849ad356e', {}],
    jsonrpc: "2.0",
    id: "2"
}, function (err, result) {
    ...
});

Then, you'll need to'CREATE', 'CALL', 'CALLCODE' and 'DELEGATECALL' opcodes and keep track of the stack.

Runic answered 24/10, 2018 at 14:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.