This repository contains Node.js scripts for extracting Ethereum transaction data given their hashes. It uses Alchemy as the Ethereum node and Web3.js library for interacting with Ethereum blockchain.
There are two scripts in this project:
-
getTxDetails.js: This script extracts details of multiple Ethereum transactions and saves the data into a CSV file. It leverages the json2csv library for formatting the output data. -
getSingleTxDetails.js: This script extracts details of a single Ethereum transaction and saves the data into a CSV file.
Before you begin, you need to have Node.js and npm (Node Package Manager) installed on your machine. You can download Node.js and npm from the official site. To check the installation, open your terminal and run:
node --version
npm --version- Clone the repository:
git clone https://github.com/your-username/eth-tx-extractor.git
cd eth-tx-extractor- Install the dependencies:
npm install- Create a
.envfile in the root directory and add your Alchemy API key:
ALCHEMY_API_KEY=your_alchemy_api_keyReplace your_alchemy_api_key with your actual Alchemy API key.
-
Prepare a CSV file named
transaction_hashes.csvin the root directory. The file should contain the Ethereum transaction hashes you want to extract the details for. -
Run the script:
node getTxDetails.js- The script will create a new file named
transactions.csvin the root directory. This file contains the details of the Ethereum transactions.
- You need to replace the
hashvalue in the script with your transaction hash.
const hash = 'your_transaction_hash'; // Replace with your transaction hash- Run the script:
node getSingleTxDetails.js- The script will create a new file named
transaction.csvin the root directory. This file contains the details of the single Ethereum transaction.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.