This repository contains two main Go binaries:
- CLI (ethcli) – A command-line tool for parsing Ethereum blocks and fetching transactions.
- HTTP Server (ethserver) – An HTTP API providing endpoints to manage subscriptions and retrieve block/transaction data.
- Environment-based Configuration: Load defaults from a
.env
file (addresses, concurrency, etc.). - Concurrency: Process blocks in parallel with a worker pool.
- Pluggable Storage: Use in-memory or switch to a database (e.g., PostgreSQL) to store transactions.
- CLI & HTTP: Choose either the command-line interface or a REST API for integration.
.
├── cmd
│ ├── ethcli // CLI entrypoint
│ │ └── main.go
│ └── ethserver // HTTP server entrypoint
│ └── main.go
├── internal // Internal packages (blockfetch, rpcfetch, httphandlers, storage, etc.)
├── pkg // Reusable packages (env, logger, constants etc.)
├── .env // Environment variables (optional)
├── Makefile // Builds and runs the project
├── go.mod
├── go.sum
└── README.md
- Go (1.22+ recommended)
- Clone this repo:
git clone https://github.com/buildwithme/ethparser.git
cd ethparser
- Build the binaries using the provided Makefile:
make build
This will create the binaries ethcli
and ethserver
in the bin
directory.
Place environment variables here. For example:
# .env
# Comma-separated addresses to watch:
ADDRESSES=0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000
# RPC Endpoint for ethereum blockchain
RPC_ENDPOINT=https://cloudflare-eth.com
# Default concurrency for block fetching:
CONCURRENCY=4
# Chunk size (blocks to process per chunk):
CHUNK_SIZE=50
# Max number of retries for transient RPC errors:
MAX_RETRIES=3
# Default start block to watch:
DEFAULT_START_BLOCK=-1
# Default end block to watch:
DEFAULT_END_BLOCK=-1
# Port to run the server on:
PORT=3000
CLI flags can override .env
. For instance:
./bin/ethcli --concurrency=8 --addresses=0xDEADBEEF...
Run the CLI with default .env
settings:
make run-cli
Override concurrency or addresses:
./bin/ethcli --concurrency=8 --addresses=0x123,0x456
Help:
./bin/ethcli --help
Run the server with default .env
settings:
make run-server
Specify custom address:
./bin/ethserver -port 9090
- POST /subscribe?address=0x1234 → Adds an address.
- GET /transactions?address=0x1234 → Returns all transactions for that address.
- GET /current-block → Shows the last processed block.
Remove compiled binaries:
make clean
- Fork the repo and create a new branch for your feature/fix.
- Commit changes with clear messages.
- Pull request into the
main
branch.