Is there a simple way to export all transactions related to a specific account/smartcontract to a CSV or some other plain text format?
-
Possible duplicate of Ether Historical Prices– Richard HorrocksCommented May 3, 2016 at 8:30
-
Two totally different questions in my eyes.– q9fCommented May 3, 2016 at 8:36
-
Different questions in my eyes too.– BokkyPooBahCommented May 3, 2016 at 8:57
-
2Agreed - please ignore.– Richard HorrocksCommented May 3, 2016 at 9:17
8 Answers
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.– JVCCommented Mar 17, 2017 at 17:02
-
@JonathanvanClute it looks to be Unix timestamp. Try to check if this is the right format using timestamp.fr Commented Mar 17, 2017 at 17:05
-
1Yep was Unix, thanks!. Used the formula here to convert to date: extendoffice.com/documents/excel/…– JVCCommented Mar 17, 2017 at 17:24
-
This does not work for smart contracts only for account (it gives you the list of where the address is the one submitting to the chain, not contract interactions.) Commented Apr 10, 2022 at 9:30
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 |
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
-
I have found another good resource for The DAO creation monitoring: daostats.github.io/tokenvol.html– AlexCommented May 8, 2016 at 9:05
-
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.
-
-
Yes. We changed about a year ago right around the time we got our EF grant. Commented Feb 9, 2020 at 19:48
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.
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.
To export Ethereum data, you may rely on a number of public nodes listed at ethereumnodes.com: some of them are free of charge.
They provide access to JSON RPC API which allows you to export blocks, transactions and other blockchain data in JSON.
Here is a modern approach to export the full history of Ethereum into S3 using the public nodes: “How to Export a Full History of Ethereum Blockchain to S3” (Medium). When exported to S3, you may reformat your data into CSV or more storage-efficient format like Parquet (and GZIP for even greater storage costs!).
As an alternative, you may rely on BigQuery public datasets with Ethereum data. This will free your hands from exporting the data. Using BigQuery datasets is also covered by the article.
Etherscan now provides this capability built in!
Go to etherscan and list all transactions for your account. Then at the bottom hit the "Download CSV export" button.
On the resulting .CSV file there are two columns one for Txn fee in ETH and one for Txn fee in USD