Reputation: 2803
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);
Upvotes: 22
Views: 53175
Reputation: 20152
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/
Upvotes: 8
Reputation: 302
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.
Upvotes: -5
Reputation: 69
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:
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.
Upvotes: 6
Reputation: 2803
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.
Upvotes: 18