Skip to main content

Do arbitrary things in reaction to Ercoin transfers

Project description

ern_reactor is a Python library that allows performing arbitrary actions in reaction to Ercoin transfers, with live synchronization and catching up after coming back online. Licensed under Apache License 2.0. Python 3.8 or newer is required.

How to use

See the help for ern_reactor.ErcoinReactor:

import ern_reactor
help(ern_reactor.ErcoinReactor)

You need to implement the get_namespace and process_tx methods. To inspect the structure of the transaction dictionary which is passed to process_tx, see ern_reactor.TransferTx.__annotations__.

A basic example

This scripts connects to a local Ercoin node and live prints transaction values for transfers received by an Ercoin address (Base64-encoded) specified on the command line:

import asyncio
import decimal
import sys

from ern_reactor import ErcoinReactor


class DummyReactor(ErcoinReactor):
    def get_namespace(self):
        return 'dummy'

    async def process_tx(self, tx):
        amount_in_ern = decimal.Decimal(tx['value']) / 10**6
        print(f'Received {amount_in_ern} ERN')


if __name__ == '__main__':
    reactor = DummyReactor(
        node='127.0.0.1',
        to_address=sys.argv[1],
        ssl=False,
    )
    try:
        asyncio.run(reactor.start())
    except KeyboardInterrupt:
        sys.exit(0)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ern_reactor-0.2.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

ern_reactor-0.2.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file ern_reactor-0.2.1.tar.gz.

File metadata

  • Download URL: ern_reactor-0.2.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.7

File hashes

Hashes for ern_reactor-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7adfaff49d94bf91519ec0c46d3edaba9568edd7c9473e28816e405b9f523bd5
MD5 c90c6e94dff6ed9fac995a3f43ca8b6b
BLAKE2b-256 056e67e2837f4171a3cae8fc07cb1ae0ad1d23e1a63c934b9c30c9d988122e03

See more details on using hashes here.

File details

Details for the file ern_reactor-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: ern_reactor-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.7

File hashes

Hashes for ern_reactor-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f501859802b8afd2e91fc6ab5a796f764f41d916cd6773d518d0e05e13f100b7
MD5 3cf4e527e2192184838cc969bcdd6e55
BLAKE2b-256 1211ca704458edd5d95638ad866042f894de8ca3051b214bbc56f4b3c63142bc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page