RaiBlocks Python RPC client for rai_node
Project description
This library contains a python wrapper for the RaiBlocks RPC server which tries to make it a little easier to work with by converting RPC responses to native python ones and exposing a pythonic api for making RPC calls.
Also included are utilities such as converting rai/xrb and interesting accounts
Installation
pip install raiblocks
RPC client
>>> from raiblocks import RPCClient
>>> rpc = RPCClient('http://localhost:7076')
>>> rpc.version()
{
'rpc_version': 1,
'store_version': 10,
'node_vendor': 'RaiBlocks 9.0'
}
>>> rpc.peers()
{
'[::ffff:75.171.168.5]:7075': 4,
'[::ffff:108.44.38.183]:1032': 4
}
Conversion
>>> from raiblocks import convert
>>> convert(12, from_unit='XRB', to_unit='raw')
Decimal('1.2E+31')
>>> converter(0.4, from_unit='krai', to_unit='XRB')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: float values can lead to unexpected
precision loss, please use a Decimal or string
eg. converter('0.4', 'krai', 'XRB')
>>> convert('0.4', from_unit='krai', to_unit='XRB')
Decimal('0.0004')
Known Accounts / Constants
>>> from raiblocks import GENESIS_BLOCK_HASH
>>> GENESIS_BLOCK_HASH
'991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948'
>>> from raiblocks import KNOWN_ACCOUNT_IDS
>>> KNOWN_ACCOUNT_IDS['xrb_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est']
'Developer Fund'
>>> from raiblocks import KNOWN_ACCOUNT_NAMES
>>> KNOWN_ACCOUNT_NAMES['Burn']
'xrb_1111111111111111111111111111111111111111111111111111hifc8npp'
Development
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt -r test-requirements.txt
python setup.py develop
Tests
# regular
pytest
# coverage
./coverage
Docs
cd docs
# generate once
make html
# live building
make live
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file raiblocks-1.0.0.tar.gz.
File metadata
- Download URL: raiblocks-1.0.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b58eebfdb74e44ae92029d192158f5f97ca599345d147c4296c03ba4716f1a2
|
|
| MD5 |
ba80676d631de95d481e5f8a392b5ab8
|
|
| BLAKE2b-256 |
a5f18ac264dc38adffe8e99a4c2f53c4de53f7f507b913a7d3fabf5a78954f01
|
File details
Details for the file raiblocks-1.0.0-py2.py3-none-any.whl.
File metadata
- Download URL: raiblocks-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
404d21b67294db8f3bdf31d3f5550cc54daf7ecb999c86e7200619835f2d759d
|
|
| MD5 |
bcbb45eb769ecb4ba32016952070b14d
|
|
| BLAKE2b-256 |
bf2787c1827ffd77dd5df8933336e32c78452901937a0ee3c21847083ee771da
|