A Go-based Ethereum blockchain parser that allows users to subscribe to Ethereum addresses and retrieve transactions. The project supports both CLI and HTTP API modes for interacting with the parser.
- Subscribe to Ethereum Addresses: Add addresses to monitor for transactions.
- Fetch Current Block Number: Get the latest block number from the Ethereum blockchain.
- Retrieve Transactions: Get all inbound or outbound transactions for a subscribed address.
- HTTP API and CLI: Interact with the parser via HTTP API or command-line interface (CLI Still work in progress).
- Clone the repository:
git clone https://github.com/yourusername/ethereum-tx-parser.git
- Navigate to the project directory:
cd ethereum-tx-parser - Build the application:
go build -o ethereum-tx-parser cmd/main.go
Run the application in HTTP API mode to expose the parser functionality via REST endpoints.
-
Start the HTTP server:
./ethereum-tx-parser -mode api
-
Use the following endpoints to interact with the API:
Subscribe to an Ethereum Address
GET /subscribe?address=0xYourEthereumAddressGet the Current Block Number
GET /blockGet Transactions for a Subscribed Address
GET /transactions?address=0xYourEthereumAddressExample Requests
curl http://localhost:8080/subscribe?address=0xYourEthereumAddress
curl http://localhost:8080/block
curl http://localhost:8080/transactions?address=0xYourEthereumAddressRun the application in CLI mode to interact with the parser via the command line.
Subscribe to an Ethereum Address:
./ethereum-tx-parser -mode cli subscribe 0xYourEthereumAddressGet the Current Block Number:
./ethereum-tx-parser -mode cli blockGet Transactions for a Subscribed Address:
./ethereum-tx-parser -mode cli transactions 0xYourEthereumAddressThis project uses GitHub Actions to run automated tests on every push to the main branch. The tests ensure that the parser, API endpoints, and CLI functionality work as expected.
To run the tests locally, use the following command:
go test ./tests/...ethereum-tx-parser/
├── cmd/
│ ├── main.go # Entry point for the application
│ ├── cli/ # CLI commands
│ └── api/ # HTTP API server
├── internal/
│ ├── parser/ # Parser implementation
│ ├── rpc/ # Ethereum JSON-RPC client
│ └── models/ # Data models
├── tests/ # Automated tests
│ ├── parser_test.go # Unit tests for the parser
│ ├── cli_test.go # CLI integration tests
│ └── api_test.go # HTTP API tests
├── README.md # Project documentation
└── go.mod # Go module file
- Go Modules: Used for dependency management.
- Cobra: A library for building powerful CLI applications.
- net/http: Used for creating the HTTP API server.
- In-Memory Storage: The project uses in-memory storage for simplicity. This can be extended to support databases like PostgreSQL or Redis.
- No Authentication: The HTTP API does not include authentication. This can be added for production use.
- Single RPC Endpoint: The project uses a single Ethereum RPC endpoint. Load balancing or failover mechanisms can be added for robustness.
- Database Integration: Replace in-memory storage with a persistent database.
- Authentication: Add API key or JWT-based authentication for the HTTP API.
- WebSocket Support: Add WebSocket support for real-time transaction notifications.
- Dockerization: Create a Docker image for easy deployment.
- Logger: Integrate a logging system with support for syslog to enhance observability, debugging, and monitoring of the application.
- CLI: Add the ability to use CLI for all commands. Right now only partial logic.
This project is licensed under the terms of the MIT license.