Package: eth-index
eth-indexeth-index is an indexer for events on the ethereum blockchain. It
imports events into a postgresql database. It’s a companion to the
trustlines project relay server component.InstallationBefore trying to install py-eth-index, make sure you have the postgresql
development header files and library installed. On debian based systems
this can be done by running:apt install libpq-deveth-index uses python 3.8 or up. Please make sure you have the required
version installed.Please checkout the source code from github, cd into the checked out
repo and run the folllowing pip command with a fresh virtualenv:pip install -c constraints.txt  .NoteOn Mac Big Sur - if the installation is failing due to compilation errros, make sure that you use openssl, readline, zlib, sqlite libs from brew and not the one that come bundles with Mac OS. Make sure yourLDFLAGSandCPPFLAGSare properly set. For more info read here:https://github.com/psycopg/psycopg2/issues/1200DevelopmentA complete development environment can be installed with:pip install -c constraints.txt -r requirements.txt
pip install -c constraints.txt -e .This installs black, flake8, mypy and tox among other things.blackThe source code is formatted withblack. If
you choose not to use the pre-commit hook, you should be able to format the
source code withblack setup.py src.flake8We use flake8 to check for errors. Runflake8 srcto check for errors.mypymypy is used to check for type errors. Runmypy--ignore-missing-importssrcto check manually.toxRunningtoxwill run black, flake8, mypy and pytest locally.Since we also do run some tests for postgres, the postgres database server must
be installed on the local machine. It doesn’t have to be started though, since
the tests do start postgres with a temporary data directory.On a debian based systemapt install postgresqlwill install the postgresql
database.pre-commitThe repository comes with a configuration file forpre-commit. pre-commit will be installed as part of
the development dependencies specified in requirements.txt. The git
commit hooks can be activated withpre-commitinstallinside the
py-eth-index repository.Initializing the databasePlease setup a working postgres environment, i.e. set the PG*
environment variables and configure ~/.pgpass.Then runethindex createtablesto create the database tables.ethindexethindex is a command line program that is being used to run the actual
syncing process. It also uses the PG* variables in order to determine
the postgres server to connect to.ethindex importabiBefore importing events into the postgres database, the ABIs must be
known.ethindex importabican be used to import ABIs into the postgres
database. By default it reads the json fileaddresses.jsonfrom the current directory
and adds the default abi for currency networks to the abis table.
A custom abi file can be provided via--contractsoption. The location of theaddresses.jsonfile can be specified via the--addressescommand line argument.Usage:Usage: ethindex importabi [OPTIONS]

Options:
  --addresses TEXT
  --contracts TEXT
  --help            Show this message and exit.ethindex runsyncethindex runsyncwill start the actual synchronization process. On
the first start it will read all of the abis and create one entry in the
sync table containing all contract addresses. It then imports all of the
events into the postgres tableevents.UsageUsage: ethindex runsync [OPTIONS]

Options:
  --jsonrpc TEXT                  jsonrpc URL to use
  --required-confirmations INTEGER
                                  number of confirmations until we consider a
                                  block final
  --waittime INTEGER              time to sleep in milliseconds waiting for a
                                  new block
  --startblock INTEGER            Block from where events should be synced
  --syncid TEXT                   syncid to use
  --merge-with-syncid TEXT        syncid to merge with
  --help                          Show this message and exit.Adding new contractsImport the contracts using theethindex importabicommand. Then synchronize
these contracts and merge them with thedefaultsyncid with something like the
following command:ethindex runsync --syncid new --merge-with-syncid defaultThis command will synchronize all contracts, which aren’t already synchronized
for thedefaultsyncid and will merge thenewsyncid into thedefaultsyncid, when both of them are fully synchronized with the chain. This means that
a runsync job has to be running fordefault.Status and Limitationsethindex is alpha software.Change logSeeCHANGELOG.