Python integration library for REMChain.
Project description
Remme Python Client
An open source Python integration library for REMChain, simplifying the access and interaction with Remme nodes both public or permissioned.
How to use
1. Install Remme protocol
Install and run Remme protocol with required RPC API methods enabled.
You can check out how to do that at Remme core repo.
2. Install dependencies:
Before installing the library, make sure that all the dependencies listed are installed.
Required by one of the requirements system packages list
$ sudo apt-get update
$ sudo apt-get install python3-dev python3-setuptools -y
$ sudo apt-get install build-essential automake libtool pkg-config libffi-dev -y
3. Install library
Install the latest version of library to your Python project from terminal using pip
:
$ pip3 install remme
Examples
Remme client
from remme import Remme
from remme.models.account.account_type import AccountType
account_config = {
'private_key_hex': 'f4f551c178104595ff184f1786ddb2bfdc74b24562611edcab90d4729fb4bab8',
'account_type': AccountType.USER,
}
network_config = {
'node_address': 'localhost:8080',
'ssl_mode': False,
}
remme = Remme(account_config=account_config, network_config=network_config)
Tokens
remme_address = '1120077f88b0b798347b3f52751bb99fa8cabaf926c5a1dad2d975d7b966a85b3a9c21'
balance = await remme.token.get_balance(address=remme_address)
print(f'Account — {remme_address}, balance — {balance} REM.')
transaction_result = await remme.token.transfer(address_to=remme_address, amount=10)
print(f'Transaction batch id: {transaction_result.batch_id}')
Certificates
certificate_transaction_result = await remme.certificate.create_and_store(
common_name='user_name',
email='user@email.com',
name='John',
surname='Smith',
country_name='US',
validity=360,
serial=str(datetime.now())
)
certificate = certificate_transaction_result.certificate
while True:
try:
info = await remme.certificate.get_info(certificate)
print(f'Info: {info.data}')
certificate_status = await remme.certificate.check(certificate)
print(f'Certificate is valid: {certificate_status}')
break
except RpcGenericServerDefinedError:
continue
Subscribing to Events
RemmeEvents is enums which describe all available events.
from remme.models.websocket.events import RemmeEvents
events = await remme.events.subscribe(events=RemmeEvents.AtomicSwap.value)
async for response in events:
print("connected")
if isinstance(response, dict):
print(response)
else:
print(f'State: {response.state}')
print(f'Sender address: {response.sender_address}')
print(f'Receiver address: {response.receiver_address}')
print(f'Amount: {response.amount}')
Also we give a possibility to start listen events from previous block by providing last known block id.
from remme.models.websocket.events import RemmeEvents
events = await remme.events.subscribe(
events=RemmeEvents.AtomicSwap.value,
last_known_block_id='db19f0e3b3f001670bebc814e238df48cef059f3f0668f57702ba9ff0c4b8ec45c7298f08b4c2fa67602da27a84b3df5dc78ce0f7774b3d3ae094caeeb9cbc82',
)
async for response in events:
print("connected")
if isinstance(response, dict):
print(response)
else:
print(f'State: {response.state}')
print(f'Sender address: {response.sender_address}')
print(f'Receiver address: {response.receiver_address}')
print(f'Amount: {response.amount}')
Unsubscribe from listening events.
await remme.events.unsubscribe(events=RemmeEvents.AtomicSwap.value)
Contributing
Clone the project and install requirements:
$ git clone git@github.com:Remmeauth/remme-client-python.git && cd remme-client-python
$ pip3 install -r requirements.txt
$ pip3 install -r requirements-dev.txt
If you prefer working with the Docker, follow:
$ git clone git@github.com:Remmeauth/remme-client-python.git && cd remme-client-python
$ docker build -t remme-client-python . -f Dockerfile
$ docker run -v $PWD:/remme-client-python --name remme-client-python remme-client-python
Enter the container bash, check Python
version and run tests:
$ docker exec -it remme-client-python bash
$ root@98247c92404d:/remme-client-python# python --version
$ root@98247c92404d:/remme-client-python# pytest -vv tests
Clean container and images with the following command:
$ docker rm $(docker ps -a -q) -f
$ docker rmi $(docker images -q) -f
License
Remme software and documentation are licensed under Apache License Version 2.0 <LICENSE>
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file remme-1.1.1.tar.gz
.
File metadata
- Download URL: remme-1.1.1.tar.gz
- Upload date:
- Size: 60.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cabccaeac154f8904589dd56ac34aa44125a678c679fcae2c38dd494fb63a1fb |
|
MD5 | daba1f35803608f7d289b1b8c874b610 |
|
BLAKE2b-256 | b8e15871831a2979943b8fa130000a9c59a5a2635dc4401e2064662f3a249c8c |