Skip to content

Commit 1659825

Browse files
committed
update README to match new configuration through environment variables
1 parent 3ee21b2 commit 1659825

File tree

1 file changed

+97
-36
lines changed

1 file changed

+97
-36
lines changed

README.md

+97-36
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,111 @@ This application extracts transactions from the Ethereum blockchain and exports
44

55
## Run
66
* You'll need an Ethereum node in order to execute API requests. If you don't have your own net yet, then you can start a local Ethereum node as a Docker container with this command:
7-
```bash
8-
docker run -d --name ethereum-node -v /home/user/ethereum:/root -p 8545:8545 -p 30303:30303 \
9-
ethereum/client-go --rpc --rpcapi "eth,net,web3" --rpcaddr 0.0.0.0 --syncmode "fast"
10-
```
7+
```bash
8+
docker run \
9+
--name ethereum-node \
10+
-v /home/user/ethereum:/root \
11+
-p 8545:8545 \
12+
-p 30303:30303 \
13+
ethereum/client-go \
14+
--rpc \
15+
--rpcapi "eth,net,web3" \
16+
--rpcaddr 0.0.0.0 \
17+
--syncmode "fast"
18+
```
1119

12-
* You'll also need a local installation of Golang to run this application:
13-
```bash
14-
go get ./...
15-
go build
16-
LOGXI=* ./ethereum-blockchain-transaction-csv-export -start 46147 -count 10
17-
```
18-
This demo should fetch the blocks 46147 through 46157 including the first ever made transaction on the Ethereum blockchain.
20+
* This application is dockerized. Use these commands to build and run the application:
21+
```bash
22+
docker build -t ethereum-blockchain-transaction-csv-export .
1923

20-
:warning: It might take some time, until your Ethereum node synchronized enough blocks to respond to API requests for those blocks. You can also set the flag `--start` to `0`. But, keep in mind that about the first 46.000 blocks of the Ethereum blockchain contain any transactions.
24+
# create directory for log and CSV files
25+
mkdir ./output/
26+
27+
docker run \
28+
--network host \
29+
-v $(pwd)/output:/output \
30+
-e LOGXI="*" \
31+
-e START_BLOCK_HEIGHT="46147" \
32+
-e BLOCK_COUNT="10" \
33+
ethereum-blockchain-transaction-csv-export
34+
```
35+
36+
This demo should fetch the blocks 46147 through 46157. These blocks contain only one transaction, the first transaction that was ever made on the Ethereum blockchain.
37+
38+
* The resulting CSV export is stored in the file `./output/geth_tx_export_<yyyy-MM-dd-HH-mm-ss>.csv`. The CSV file contains the following columns:
39+
40+
| Column | Description |
41+
| ----------------- | ------------------------------------------------------------ |
42+
| tx_hash | 32 Bytes hash of the transaction. |
43+
| tx_nonce | The number of transactions made by the sender prior to this one. |
44+
| tx_block_hash | 32 Bytes hash of the block where this transaction was in. |
45+
| tx_block_number | Block number where this transaction was in. `null` when its pending. |
46+
| tx_index | Integer of the transaction's index position in the block. `null` when its pending. |
47+
| tx_from | 20 Bytes address of the sender |
48+
| tx_to | 20 Bytes address of the receiver. `null` when its a contract creation transaction. |
49+
| tx_value | Value transferred in Wei. |
50+
| tx_gas | Gas provided by the sender. |
51+
| tx_gas_price | Gas price provided by the sender in Wei. |
52+
| tx_input | The data send along with the transaction. |
53+
| tx_timestamp | Integer of the unix timestamp when the transaction was sent. |
54+
55+
56+
:warning: It might take some time, until your Ethereum node synchronized enough blocks to respond to API requests for those blocks. You can also set the environment variable `START_BLOCK_HEIGHT` to `0`. But, keep in mind that about the first 46.000 blocks of the Ethereum blockchain don't contain any transactions.
2157

2258
**Another example:**
2359

24-
This command exports all transactions contained in the first 4 million blocks (estimated time to completion: 11 hours):
60+
This command exports all transactions contained in the first 4 million blocks (this process might take several hours):
2561

2662
```bash
27-
LOGXI=WRN nohup ./ethereum-blockchain-transaction-csv-export \
28-
-count 4000000 \
29-
-blockConcurr 20 \
30-
-txConcurr 30 \
31-
&
63+
docker run \
64+
--network host \
65+
-v $(pwd)/output:/output \
66+
-e LOGXI="*=INF" \
67+
-e START_BLOCK_HEIGHT="0" \
68+
-e BLOCK_COUNT="4000000" \
69+
-e WORKER_COUNT_FOR_BLOCKS="20" \
70+
-e WORKER_COUNT_FOR_TRANSACTIONS="30" \
71+
ethereum-blockchain-transaction-csv-export
3272
```
3373

3474
## Configuration
35-
This application can be configured using command line flags. Type `--help` to find out more about the available configurations:
36-
```bash
37-
./ethereum-blockchain-transaction-csv-export --help
38-
Usage of ./ethereum-blockchain-transaction-csv-export:
39-
-blockConcurr int
40-
The count of concurrent workers for fetching block. (default 10)
41-
-count int
42-
The total amount of blocks to fetch. (default 1000)
43-
-host string
44-
The hostname / IP address of the Ethereum node. (default "127.0.0.1")
45-
-port int
46-
The port number of the Ethereum node. (default 8545)
47-
-start int
48-
The height / number of the block where to start.
49-
-statsIntervalSec int
50-
The invertal in seconds to display stats. (default 5)
51-
-txConcurr int
52-
The count of concurrent workers for fetching transactions. (default 20)
75+
76+
This application is configured via the environment. The following environment variables can be used:
77+
78+
```
79+
BLOCK_COUNT
80+
[description] The total amount of blocks to fetch.
81+
[type] Integer
82+
[default] 1000
83+
[required]
84+
HOSTNAME
85+
[description] The hostname / IP address of the Ethereum node.
86+
[type] String
87+
[default] 127.0.0.1
88+
[required]
89+
PORT
90+
[description] The port number of the Ethereum node.
91+
[type] Integer
92+
[default] 8545
93+
[required]
94+
START_BLOCK_HEIGHT
95+
[description] The height / number of the first block to fetch.
96+
[type] Integer
97+
[default] 0
98+
[required]
99+
STATS_INTERVAL_IN_SECONDS
100+
[description] The invertal in seconds to display stats.
101+
[type] Integer
102+
[default] 5
103+
[required]
104+
WORKER_COUNT_FOR_BLOCKS
105+
[description] The count of concurrent workers for fetching blocks.
106+
[type] Integer
107+
[default] 10
108+
[required]
109+
WORKER_COUNT_FOR_TRANSACTIONS
110+
[description] The count of concurrent workers for fetching transactions.
111+
[type] Integer
112+
[default] 20
113+
[required]
53114
```

0 commit comments

Comments
 (0)