Git Product home page Git Product logo

django-eth-events's Introduction

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 3.x. This app provides methods and Celery tasks to continuously decode events from ethereum blockchain and index then in a relational database. Too see an example of using this you can check Gnosis TradingDB repository and readthedocs documentation

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:

INSTALLED_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. Recommended protocol is HTTPS. For example, using https://localhost:8545 communication with node will use RPC through HTTPS

ETHEREUM_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:

ETHEREUM_MAX_WORKERS = os.environ['ETHEREUM_MAX_WORKERS']

IPFS

Provide an IPFS host and port:

IPFS_HOST = os.environ['IPFS_HOST']
IPFS_PORT = os.environ['IPFS_PORT']

Listening to Events

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

ETH_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 Gnosis TradingDB repository and check out the full documentation.

Django-eth-events development

The easiest way to start development on django-eth-events is to install dependencies using pip and a virtualenv, python3.6 is required:

virtualenv -p python3.6 venv
source venv/bin/activate
pip install -r requirements

Tests

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

Django tests can also be used

DJANGO_SETTINGS_MODULE=config.settings.test python manage.py test

Coverage can be run using coverage tool:

pip install coverage
DJANGO_SETTINGS_MODULE=config.settings.test coverage run --source=django_eth_events manage.py test

Run specific test cases

DJANGO_SETTINGS_MODULE=config.settings.test python manage.py test django_eth_events.tests.test_file

More information at https://docs.djangoproject.com/en/2.2/topics/testing/overview/#running-tests.

django-eth-events's People

Contributors

uxio0 avatar denisgranha avatar giacomolicari avatar hashcashier avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.