Skip to main content

Build Status Code style: black

eth-index

eth-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.

Installation

Before 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-dev

eth-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  .

Development

A 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.

black

The source code is formatted with black. If you choose not to use the pre-commit hook, you should be able to format the source code with black setup.py src.

flake8

We use flake8 to check for errors. Run flake8 src to check for errors.

mypy

mypy is used to check for type errors. Run mypy --ignore-missing-imports src to check manually.

tox

Running tox will 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 system apt install postgresql will install the postgresql database.

pre-commit

The repository comes with a configuration file for pre-commit. pre-commit will be installed as part of the development dependencies specified in requirements.txt. The git commit hooks can be activated with pre-commit install inside the py-eth-index repository.

Initializing the database

Please setup a working postgres environment, i.e. set the PG* environment variables and configure ~/.pgpass.

Then run

ethindex createtables

to create the database tables.

ethindex

ethindex 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 importabi

Before importing events into the postgres database, the ABIs must be known.

ethindex importabi can be used to import ABIs into the postgres database. By default it reads the json file addresses.json from the current directory and adds the default abi for currency networks to the abis table. A custom abi file can be provided via --contracts option. The location of the addresses.json file can be specified via the --addresses command line argument.

Usage:

Usage: ethindex importabi [OPTIONS]

Options:
  --addresses TEXT
  --contracts TEXT
  --help            Show this message and exit.

ethindex runsync

ethindex runsync will 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 table events.

Usage

Usage: 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 contracts

Import the contracts using the ethindex importabi command. Then synchronize these contracts and merge them with the default syncid with something like the following command:

ethindex runsync --syncid new --merge-with-syncid default

This command will synchronize all contracts, which aren’t already synchronized for the default syncid and will merge the new syncid into the default syncid, when both of them are fully synchronized with the chain. This means that a runsync job has to be running for default.

Status and Limitations

  • ethindex is alpha software.

Change log

See CHANGELOG.

Metadata

Release files for eth-index 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eth-index 0.4.1
File Size Uploaded
eth-index-0.4.1.tar.gz 24.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for eth-index 0.4.1
File Interpreter ABI Platform
eth_index-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.0 kB

Release files / eth-index-0.4.1.tar.gz

Download URL eth-index-0.4.1.tar.gz
Size 24.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2c45074364d562246881874f3dee8bb4f88dc1555d797f6559cb2c0c1ef5017c
BLAKE2b-256 checksum
How to use checksums
60d42d531933532fe367195fb1965b26d496444283cbc24aec1aa5c583c6fa2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.6.9

Release files / eth_index-0.4.1-py3-none-any.whl

Download URL eth_index-0.4.1-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d04803cad8babf7bbce037613743ed3534e71b61527530034a010cd0c14d8a08
BLAKE2b-256 checksum
How to use checksums
91afb1fd1350a5971ed2319d656cf2ca37217b4e6565f11ea4d2064624628b75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page