A proof of concept (POC) implementation of multichain indexer for ethereum based chains and layer 2 solutions.
- Scans multiple ethereum based chains and layer 2 blockchain nodes
- Provides api's to fetch tx history of address across multiple chains
- Exposes adapter to publish transaction details
- Built on node version: v20.9.0
- NodeJS LTS version
- MySql
clone the repo and cd blockchain-indexer
npm install
See enviroment variables in src/config.ts
DB_URL=mysql://john:doe@localhost:3306/indexer
DB_HOST=127.0.0.1
DB_NAME=indexer
DB_PORT=3306
DB_USER=john
DB_PASS=doe
npm run start
Run with docker
docker compose up
- See src/config.ts for chain config
- Feel free to add more EVM compatible chains
- Currently src/config.ts includes ETH and GNOSIS chains
To start the server, run the following
npm start
Get txs for an address:
http://localhost:3000/api/<chainName>/<testnet|mainnet>/address/<address>/txs
http://localhost:3000/api/ETH/testnet/address/0xb733B99F0f9b690C47004A835CA25e32992194DF/txs
http://localhost:3000
http://localhost:3000/api/GNOSIS/mainnet/block/1000
http://localhost:3000/api/ETH/testnet/address/0xb733B99F0f9b690C47004A835CA25e32992194DF/coins
Adapter implementation is not concerete ... just sharing ideas
- It could be exposed via websockets interface
- External analyzer could register a callback to receive the tx or blocks
- OR it could be a json rpc interface served over http
Design should be included but see src/models folder for now
src
|____types
| |____Class.ts
| |____Config.ts
| |____ChainNetwork.ts
| |____Worker.ts
|____utils
| |____wait.ts
|____models
| |____State.ts
| |____Block.ts
| |____Transaction.ts
|____logger.ts
|____config.ts
|____modules
| |____eth
| | |____p2p
| | | |____p2p.ts
| | | |____sync_worker
| | | | |____syncWorker.ts
| | | | |____sync.ts
| | |____index.ts
| |____index.ts
|____server.ts <--- Entry point
|____routes
| |____adapter
| | |____index.ts
| |____api
| | |____block.ts
| | |____transaction.ts
| | |____address.ts
| |____index.ts
|____services
| |____storage.ts
| |____api.ts
| |____p2p.ts
| |____config.ts
| |____worker.ts
- See NOTES.md file for more information
- See comments in code for more understanding
Contribute to blockchain indexer by opening a pull request. See contributions.md for more details.
Last updated: 25 December, 2024