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
Documentation
RPC client
You can browse the available RPC methods list or check the RPC Client API documentation for examples of usage.
>>> 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')
>>> convert(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. convert('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
Setup
virtualenv venv
source venv/bin/activate
pip install -r requirements.pip -r requirements-dev.pip
python setup.py develop
Running tests
# regular
pytest
# coverage
./coverage
Building docs
cd docs
# generate once
make html
# live building
make live
Making a release
Update CHANGELOG.rst
bumpversion [major|minor|patch]
python setup.py upload
Metadata
Release files for raiblocks 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| raiblocks-1.1.0.tar.gz | 23.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| raiblocks-1.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 47.3 kB
Release files / raiblocks-1.1.0.tar.gz
| Download URL | raiblocks-1.1.0.tar.gz |
|---|---|
| Size | 23.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57bb9e2267d41731c591357ee9af400642b53bf5afade05162c7327c5178de5c
|
|
BLAKE2b-256 checksum How to use checksums |
d959d32309d135ff073934fa02f4ec7047976446a1101391728fdde74d8ae800
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / raiblocks-1.1.0-py2.py3-none-any.whl
| Download URL | raiblocks-1.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 24.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b06576cf1547f7b53a7a30f3f1edc46a962ac021bd01b464a98d7d938b2d8c8f
|
|
BLAKE2b-256 checksum How to use checksums |
babc6dc40c5e5bccb92228616a19b911ae4c5b3c92cd0cb6bd21df313885c452
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for raiblocks 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.