A standalone Django app for decoding Ethereum events compatible with Python 2.7 and 3.x
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',
...
)
Provide an Ethereum host, port and SSL (0, 1). Use SSL = 1 only if your Ethereum host supports HTTPS/SSL. Communication with node will use RPC through HTTP/S
ETHEREUM_NODE_HOST = os.environ['ETHEREUM_NODE_HOST']
ETHEREUM_NODE_PORT = os.environ['ETHEREUM_NODE_PORT']
ETHEREUM_NODE_SSL = bool(int(os.environ['ETHEREUM_NODE_SSL']))
You can also provide an IPC path to a node running locally, which will be faster. You can use the environment variable ETHEREUM_IPC_PATH. If set, it will override ETHEREUM_NODE_HOST and ETHEREUM_NODE_PORT, so IPC will be used instead of RPC:
ETHEREUM_IPC_PATH = os.environ['ETHEREUM_IPC_PATH']
Number of concurrent threads connected to the ethereum node can be configured:
ETHEREUM_MAX_WORKERS = os.environ['ETHEREUM_MAX_WORKERS']
Provide an IPFS host and port:
IPFS_HOST = os.environ['IPFS_HOST']
IPFS_PORT = os.environ['IPFS_PORT']
Create a new array variable in your settings file and call it ETH_EVENTS 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 GnosisDB repository and check out the full documentation: link.
You can launch tests using python run_tests.py
. No additional services are required.
Django tests can also be used
export DJANGO_SETTINGS_MODULE=settings.test
export PYTHONPATH="/folder/to/project/django-eth-events"
python django_eth_events/manage.py test
Coverage can be run using coverage tool:
pip install coverage
coverage run --source=django_eth_events django_eth_events/manage.py test