{"id":37154162,"url":"https://github.com/ilkamo/ethparser-go","last_synced_at":"2026-01-14T18:10:37.962Z","repository":{"id":234923017,"uuid":"789163428","full_name":"ilkamo/ethparser-go","owner":"ilkamo","description":"Easy extendable Ethereum parser.","archived":false,"fork":false,"pushed_at":"2024-04-22T15:46:07.000Z","size":81,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-28T22:02:53.027Z","etag":null,"topics":["blockchain","ethereum","parser"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ilkamo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-04-19T20:38:26.000Z","updated_at":"2024-04-25T10:24:08.000Z","dependencies_parsed_at":"2024-04-22T02:16:27.974Z","dependency_job_id":"155a407e-0fe9-4512-adb2-d2e6c7edaa41","html_url":"https://github.com/ilkamo/ethparser-go","commit_stats":null,"previous_names":["ilkamo/trustwallet-parser-task","ilkamo/ethparser-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ilkamo/ethparser-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilkamo%2Fethparser-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilkamo%2Fethparser-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilkamo%2Fethparser-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilkamo%2Fethparser-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ilkamo","download_url":"https://codeload.github.com/ilkamo/ethparser-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilkamo%2Fethparser-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28429789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T16:38:47.836Z","status":"ssl_error","status_checked_at":"2026-01-14T16:34:59.695Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","ethereum","parser"],"created_at":"2026-01-14T18:10:37.329Z","updated_at":"2026-01-14T18:10:37.957Z","avatar_url":"https://github.com/ilkamo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ethereum Parser\n\nI had a lot of fun working on this project. My approach was to create a parser that could be easily extended with new\nrepositories and ethereum clients. Most of the code is tested with unit tests and I tried to keep it as clean as possible.\nThe most interesting parts are commented in the code so that reviewers can understand my thought process.\n\n## Packages\n\nI created different packages to have a separation of concerns and I used the `internal` package for the components that I don't want to expose to the public.\n\n- `internal`\n  - `e2e` e2e test suite.\n  - `ethereum` logic to interact with the needed methods of the ethereum client. It relies on a generic `RPCClient` interface that can be implemented by any client. Inside the package, there are some utility functions to deal with ethereum hex numbers.\n  - `jsonrpc` logic to interact with any JSON-RPC server. It is used by my ethereum client.\n    Inside, there are some **transport-layer** types. The `HTTPRequestBuilder` is a really simple builder, and it could be\n    replaced with a more generic one.\n  - `storage` implementation of an in-memory concurrency safe `TransactionsRepository`\n    and `AddressesRepository`.\n  - `mock` mocks for the tests.\n  - `testdata` test data used by the tests. Here I used **go:embed** to simply load a json file with real ethereum block\n    data. \n\n\n- `parser` logic to parse and observe the ethereum blocks and transactions. The parser accepts\n  different options to enhance the default implementation with more sophisticated components.\n\n\n- `types` types used by the main components.\n\n\n## Usage\n\nThe default parser can be initialized in the following way:\n\n```go\nctx := context.Background()\nlog := slog.New(slog.NewJSONHandler(os.Stdout, nil))\n\np, err := parser.NewParser(\n  \"https://cloudflare-eth.com\",\n  log,\n)\n// handle the error\n\nerr = p.Run(ctx)\n```\n\nThe parser can be extended with different components by passing options to the constructor. For example, to use a different repository, you can pass the `WithTransactionsRepository` option:\n\n```go\nrepo := NewTransactionsRepository()\n\np, err := parser.NewParser(\n  \"https://cloudflare-eth.com\",\n  log,\n  parser.WithTransactionsRepository(repo),\n)\n```\n\nAll the available options are defined in the [parser/options.go](parser/options.go) file.\n\n\n## Testing\n\nAll the unit tests can be run with the following command:\n\n```bash\nmake test\n```\n\nTo display the tests coverage in an interactive html page, run the following command:\n\n```bash\nmake display_coverage\n```\n\nIn addition, I created a simple e2e test suite that runs the parser with a real ethereum client to show that it works as\nexpected. The test is located in the `tests/e2e` folder. Usually I would run this with a docker-compose file that would start an ethereum emulator, but wanted to keep it simple for this project. To\nstart the test, just run the following command:\n\n```bash\nmake test_e2e\n```\n\n## Linting\n\nTo lint the code, run the following command:\n\n```bash\nmake lint\n```\n\nTo fix linting issues, run the following command:\n\n```bash\nmake fmt\n```\n\n## CI\n\nI added a simple GitHub Actions workflow that runs the tests and linter on every pull request.\n\n## Considerations\n\n```go\ntype Parser interface {\n    GetCurrentBlock() int\n    Subscribe(address string) bool\n    GetTransactions(address string) []Transaction\n}\n```\n\nDuring the implementation, I thought about some improvements that could be made to the **public interface** of the **parser**.\n\n- `context` is not being used in the parser methods. I would definitely add it in a real-world scenario to allow the\n  caller to cancel the operation and pass trace information.\n- The `Subscribe` and `GetTransactions` methods could be improved to return an error. This way, the caller could know if\n  the subscription failed and why (really useful it there is a cache or a network error).\n- The parser doesn't have a method to start parsing. I assumed that it would start parsing when the parser is created. I\n  really don't like this approach this is why I added a Run method to the parser. This way, the caller can start the parser\n  and control it with a context.\n- The `GetCurrentBlock` returns an int. I would change it to return an **uint64** to avoid possible future overflow issues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filkamo%2Fethparser-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filkamo%2Fethparser-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filkamo%2Fethparser-go/lists"}