Skip to content

Simple version of Etherscan.io - Ethereum blockchain indexer with REST API and token's parser

Notifications You must be signed in to change notification settings

moonsly/eth_blockchain_indexer_rest

Repository files navigation

eth_blockchain_indexer_rest

simple version of Etherscan - Ethereum blockchain indexer with REST API

INSTALL

To run indexer you need Python3.5, after that:

  1. Install dependencies in your virtualenv:
pip install -r requirements.txt
  1. Create your PostgreSQL database, then create schema and indexes:
cat schema.sql | psql database_name
  1. Add tokens fixture to avoid long updates of token's quantity:

cat fixtures/tokens.sql | psql database_name

  1. Set your infura API key, db name, user, password in config.py.

  2. Run blockchain indexer - by default it starts parsing from 'latest' block, if you inserted some block with number=block.id - it starts from that block. It can recover automatically after failing and should be placed to supervisrod config.

. env/bin/activate
python3 ./pool.py debug

Average time of ETH block parsing (with good infura.io ping and on Ubuntu 4 core CPU 4Gb RAM) is about 2-3 seconds VS average ETH new block time is about 10-15 seconds, so it works fine in realtime with ETH blocks, and can recover missing blocks after little downtime of blockchain parsing.

  1. Add token updater to crontab - to parse new token's decimals/symbols/total supply each 5 minutes:
* * * * */5 /your_env/python3 /path_to/token_info_updater.py
  1. Start REST on localhost:
python ./rest_simple.py 

 * Serving Flask app "rest_simple" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Great! Now you should have some blockchain records in your database (parsed by pool.py) and you can filter your blockchain data via REST on URL http://127.0.0.1:5000/api

About

Simple version of Etherscan.io - Ethereum blockchain indexer with REST API and token's parser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published