9

Is there a simple way to export all transactions related to a specific account/smartcontract to a CSV or some other plain text format?

7

Or you can simply use etherscan API and Json to CSV online service.

Use API, ie: https://api.etherscan.io/api?module=account&action=txlist&address=0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae&sort=asc and put it in the URL field of http://www.convertcsv.com/json-to-csv.htm

Et voilà.

  • Handy solution, thanks for posting it! Now however, do you know what the timestamp" format in the JSON is? Excel just chokes on it both as date, time, and also as datetime. – Jonathan van Clute Mar 17 '17 at 17:02
  • @JonathanvanClute it looks to be Unix timestamp. Try to check if this is the right format using timestamp.fr – Nicolas Massart Mar 17 '17 at 17:05
  • Yep was Unix, thanks!. Used the formula here to convert to date: extendoffice.com/documents/excel/… – Jonathan van Clute Mar 17 '17 at 17:24
3

Recently, PeterChauYEG put together a node app / scraper for the DAO address that uses Etehrescan's API and outputs a CSV.

It will do the same for any address provided if you changed line 8 @ main.js: const address = '0xbb9bc244d798123fde783fcc1c72d3bb8c189413'; to the address you would like to generate a CSV from.


If you find it useful, consider supporting the developer w/ a donation: 0x1A416af553Faca53b4be48DCFB6E749C9737455D

3

Here is a guide on how to export Ethereum data to csv https://medium.com/@medvedev1088/exporting-and-analyzing-ethereum-blockchain-f5353414a94e

It uses https://github.com/medvedev1088/ethereum-etl which outputs the data into blocks.csv, transactions.csv, erc20_transfers.csv.

blocks.csv

Column                  | Type               |
------------------------|---------------------
block_number            | bigint             |
block_hash              | hex_string         |
block_parent_hash       | hex_string         |
block_nonce             | hex_string         |
block_sha3_uncles       | hex_string         |
block_logs_bloom        | hex_string         |
block_transactions_root | hex_string         |
block_state_root        | hex_string         |
block_miner             | hex_string         |
block_difficulty        | bigint             |
block_total_difficulty  | bigint             |
block_size              | bigint             |
block_extra_data        | hex_string         |
block_gas_limit         | bigint             |
block_gas_used          | bigint             |
block_timestamp         | bigint             |
block_transaction_count | bigint             |

transactions.csv

Column              |    Type     |
--------------------|--------------
tx_hash             | hex_string  |
tx_nonce            | bigint      |
tx_block_hash       | hex_string  |
tx_block_number     | bigint      |
tx_index            | bigint      |
tx_from             | hex_string  |
tx_to               | hex_string  |
tx_value            | bigint      |
tx_gas              | bigint      |
tx_gas_price        | bigint      |
tx_input            | hex_string  |

erc20_transfers.csv

Column              |    Type     |
--------------------|--------------
erc20_token         | hex_string  |
erc20_from          | hex_string  |
erc20_to            | hex_string  |
erc20_value         | bigint      |
erc20_tx_hash       | hex_string  |
erc20_block_number  | bigint      |
1

There's no built-in way to do this. How difficult it is to do depends on what you mean by "related to a specific account".

Transactions initiated by an external account are easy to look up, as 'from' is one of the fields of the transaction - though there's no API call that returns only transactions initated by a given account you can at least scan transactions looking for ones you care about.

Transactions from an external account to another, or to a contract, are easy to detect, too, since there's also a 'to' field.

Where it gets complicated, however, is for value transfers initiated by a contract. These are often called "internal transactions", though in actual fact they're not transactions at all. There's no direct record of these in Ethereum, except by their side-effects (value transferred and state changes made), so there's no easy way to export them. Blockchain explorers that provide this functionality work by tracing transaction execution in the EVM, recording details about what took place.

However, let me plug my own project, Etherquery. It's a dump of Ethereum blockchain data - blocks, transactions, and transfers - to BigQuery, which permits arbitrary analytic queries, and supports exporting to a number of formats, including CSV. BigQuery is user-pays, but the first terabyte of processing each month is free. If you don't have a Google Cloud project, you'll need to create an empty one in order to access the public tables linked above.

1

If you are writing the contract you include events in your contract to track what's happening, and then you can log those events easily to a CSV file. This will include internal transactions as well, which addresses an issue noted above.

In Solidity, you log with Events. You can then listen to all events on your contract with web3.js "allEvents" callback.

In the Javascript event allEvents callback, it's extremely easy to log to JSON (it's already an object), and logging to CSV in Javascript means just choosing an appropriate CSV library.

1

QuickBlocks does exactly this. It even picks up incoming internal transactions. Plus it exports to JSON, CSV, TEXT or any other format at the flip of switch. All while remaining 100% decentralized.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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