{"id":23129033,"url":"https://github.com/twiny/blockscan","last_synced_at":"2025-08-17T06:32:03.279Z","repository":{"id":61629150,"uuid":"550728875","full_name":"twiny/blockscan","owner":"twiny","description":"a mini blockchain scanner","archived":false,"fork":false,"pushed_at":"2022-10-13T08:46:25.000Z","size":20,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-20T02:13:23.577Z","etag":null,"topics":["blockchain","blockchain-explorer","golang","microservices","sqlite"],"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/twiny.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}},"created_at":"2022-10-13T08:26:24.000Z","updated_at":"2024-06-20T02:13:23.577Z","dependencies_parsed_at":"2022-10-19T19:00:52.313Z","dependency_job_id":null,"html_url":"https://github.com/twiny/blockscan","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fblockscan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fblockscan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fblockscan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fblockscan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twiny","download_url":"https://codeload.github.com/twiny/blockscan/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230098768,"owners_count":18172740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","blockchain-explorer","golang","microservices","sqlite"],"created_at":"2024-12-17T10:08:08.574Z","updated_at":"2024-12-17T10:08:09.328Z","avatar_url":"https://github.com/twiny.png","language":"Go","readme":"# Blockchain Explorer\n\nmini blockchain explorer - composed of two services `Rest` \u0026 `Indexer`\n\n\n### `Indexer`\nIs the backend service for the chain explorer, it gets the details of a block along with the details of transactions in it then stores them in a DB.\n\n### `Rest`\n\nAn HTTP server that read from a database and exposes public endpoints to view a range of block/transactions as well as statistics about the chain.\n\n```\n`GET /health`           - health check endpoint\n`GET /v1/index`         - instruct Indexer to perform a scan\n\n`GET /v1/block`         - get latest block in db\n`GET /v1/block/{id}`    - get a specific block \n\n`GET /v1/stats`         - get stats total amount of transactions and all transaction hashes in DB.\n`GET /v1/stats/{range}` - get stats for a range of blocks `start:end`\n\n`GET /v1/tx`            - get latest transaction id db.\n`GET /v1/tx/{hash}`     - get transaction by hash\n```\n\n#### `Indexer Store`\n\nPersistence layer `StoreWriter` an interface expose below API. \n\n```go\n// StoreWriter\ntype StoreWriter interface {\n    Ping() error\n    HasScanned(ctx context.Context, id int64) bool\n    SaveBlock(ctx context.Context, block *chain.Block) error\n    SaveTx(ctx context.Context, tx *chain.Tx) error\n}\n```\n\n#### `Rest Store`\n\n`StoreReader` reads from a DB and an interface exposing these APIs. \n```go\n// StoreReader\ntype StoreReader interface {\n    Ping() error\n    //\n    GetLatestBlock(ctx context.Context) (*chain.Block, error)\n    GetBlock(ctx context.Context, n int64) (*chain.Block, error)\n    //\n    GetLatestTx(ctx context.Context) (*chain.Tx, error)\n    GetTx(ctx context.Context, hash string) (*chain.Tx, error)\n    //\n    GetStats(ctx context.Context, i, j int64) (*chain.Stats, error)\n}\n```\n\n## Configuration\n```yaml\n# rest configuration\nrest:\n    address: \":8080\"\n\n# indexer configuration\nindexer:\n    address: \":8081\"\n    host: \"http://localhost\"\n    token: \"secret\"\n    endpoint: \"wss://mainnet.infura.io/ws/v3/{api_key}\"\n    limiter:\n        rate: 3\n        duration: \"1s\"\n    workers: 5\n    timeout: \"30s\"\n    \n# store configuration\nstore:\n    path: \"./tmp/\"\n```\n\n## Run\n\nrename file `config/example.config.yaml`  to `config/config.yaml` and uodate config as per requirement.\n\nThen, run `make inderxer` in one terminal to start the indexer service and run `make rest` in another terminal to start the rest service.\n\nonce both services are up\n```\n[rest service] 2022/10/02 19:50:05 starting http server on :8080\n[indexer service] 2022/10/02 19:50:06 starting http server on :8081\n```\n\nRun in a 3rd terminal window, to instruct the indexer to start scanning the blockchain, from block 15661751 to the latest one.\n\n```\ncurl -XGET -H \"Content-type: application/json\" 'http://localhost:8080/v1/index?scan=15661751'\n```\n\nA Success Response:\n\n```\n{\"status\":200,\"payload\":\"indexer command executed\"}\n```\n\nView Postman collection `postman/blockchain_explorer.postman_collection.json` for all `rest` service endpoints/APIs.\n\n\n## TODO\n\n- [ ] add more tests.\n- [ ] add store mocks.\n- [ ] -","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwiny%2Fblockscan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwiny%2Fblockscan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwiny%2Fblockscan/lists"}