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',
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
Built Distribution
File details
Details for the file ern_reactor-0.1.0.tar.gz
.
File metadata
- Download URL: ern_reactor-0.1.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef6cda9edd102a2a541b09d65a2122b83eb993aaa49336bdb831cd194693486d |
|
MD5 | 7fce18459cb91c90491f18d7891cc1c2 |
|
BLAKE2b-256 | f52243c753323ca8c9345f15bc63b431a5b671f2c5b559d12874b0afc5b0678f |
File details
Details for the file ern_reactor-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: ern_reactor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35b11bcef946ead473805e2860a16d19ef654c7aeb523b52441ddd9a662810e3 |
|
MD5 | 2f600151d979160b93b3f1dac70cfd85 |
|
BLAKE2b-256 | eada979e8ba28c6d96325a93b68fea6a8ef5fbdcdf3cd33c0439c9beda68550a |