Skip to content

A Go-based Ethereum blockchain parser that allows users to subscribe to Ethereum addresses and retrieve transactions.

Notifications You must be signed in to change notification settings

shay23bra/ethereum-tx-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ethereum Transaction Parser

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).

Installation

  1. Clone the repository:
    git clone https://github.com/yourusername/ethereum-tx-parser.git
  2. Navigate to the project directory:
    cd ethereum-tx-parser
  3. Build the application:
    go build -o ethereum-tx-parser cmd/main.go
    

Usage

HTTP API Mode

Run the application in HTTP API mode to expose the parser functionality via REST endpoints.

  1. Start the HTTP server:

    ./ethereum-tx-parser -mode api
  2. Use the following endpoints to interact with the API:

Subscribe to an Ethereum Address

GET /subscribe?address=0xYourEthereumAddress

Get the Current Block Number

GET /block

Get Transactions for a Subscribed Address

GET /transactions?address=0xYourEthereumAddress

Example Requests

curl http://localhost:8080/subscribe?address=0xYourEthereumAddress
curl http://localhost:8080/block
curl http://localhost:8080/transactions?address=0xYourEthereumAddress

CLI Mode (Under Development - Work in progress)

Run 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 0xYourEthereumAddress

Get the Current Block Number:

./ethereum-tx-parser -mode cli block

Get Transactions for a Subscribed Address:

./ethereum-tx-parser -mode cli transactions 0xYourEthereumAddress

Testing

Automated Testing

This 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.

Running Tests Locally

To run the tests locally, use the following command:

go test ./tests/...

Project Structure

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

Dependencies

  • Go Modules: Used for dependency management.
  • Cobra: A library for building powerful CLI applications.
  • net/http: Used for creating the HTTP API server.

Limitations

  • 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.

Future Enhancements

  • 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.

References

License

This project is licensed under the terms of the MIT license.

About

A Go-based Ethereum blockchain parser that allows users to subscribe to Ethereum addresses and retrieve transactions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages