gnosis/django-eth-events

Name: django-eth-events

Owner: GNOSIS

Description: null

Created: 2017-06-27 17:55:42.0

Updated: 2018-05-24 12:01:49.0

Pushed: 2018-05-24 12:02:15.0

Homepage: null

Size: 262

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status Coverage Status Python 3.6 Django 2 PyPI version

django_eth_events

A standalone Django app for decoding Ethereum events compatible with Python 2.7 and 3.x

Setup

If you want to install the latest stable release from PyPi:

$ pip install django-eth-events

If you want to install the latest development version from GitHub:

$ pip install -e git+https://github.com/gnosis/django-eth-events.git#egg=Package

Add django_eth_events to your INSTALLED_APPS:

ALLED_APPS = (
...
'django_eth_events',
...

Settings

Provide an Ethereum node url. Provider will be detected depending on the protocol of the url. http/s, ipc and ws(websocket) providers are available. For example, using https://localhost:8545 communication with node will use RPC through HTTPS

REUM_NODE_URL = os.environ['ETHEREUM_NODE_URL']

You can also provide an IPC path to a node running locally, which will be faster, using ipc://PATH_TO_IPC_SOCKET

Number of concurrent threads connected to the ethereum node can be configured:

REUM_MAX_WORKERS = os.environ['ETHEREUM_MAX_WORKERS']

IPFS

Provide an IPFS host and port:

_HOST = os.environ['IPFS_HOST']
_PORT = os.environ['IPFS_PORT']
Events to listen to

Create a new array variable in your settings file and call it ETH_EVENTS as follows:

EVENTS = [
{
    'ADDRESSES': ['0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B'],
    'EVENT_ABI': '... ABI ...',
    'EVENT_DATA_RECEIVER': 'yourmodule.event_receivers.YourReceiverClass',
    'NAME': 'Your Contract Name',
    'PUBLISH': True,
},
{
    'ADDRESSES_GETTER': 'yourmodule.address_getters.YouCustomAddressGetter',
    'EVENT_ABI': '... ABI ...',
    'EVENT_DATA_RECEIVER': 'chainevents.event_receivers.MarketInstanceReceiver',
    'NAME': 'Standard Markets Buy/Sell/Short Receiver'
}

Take a look at GnosisDB repository and check out the full documentation: link.

Tests

You can launch tests using python run_tests.py. No additional services are required.

Django tests can also be used

rt DJANGO_SETTINGS_MODULE=settings.test
rt PYTHONPATH="/folder/to/project/django-eth-events"
on django_eth_events/manage.py test

Coverage can be run using coverage tool:

install coverage
rage run --source=django_eth_events django_eth_events/manage.py test

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.