Skip to content

Commit 14bf34f

Browse files
committed
added reStructuredText readme for rendering on package's PyPi homepage
1 parent 2e2eca8 commit 14bf34f

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

docs/readme.rst

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
Rubix Client SDK for Python
2+
============================
3+
4+
``rubix-py`` is a lightweight client for the Rubix Blockchain Node, providing complete node interaction with minimal overhead.
5+
6+
⚠️ This project is currently under **active development**. API changes and method signature updates may occur between releases. Please review the **Release Notes** before upgrading.
7+
8+
Installation
9+
============
10+
11+
Run the following to install ``rubix-py``
12+
13+
.. code-block:: shell
14+
15+
pip install rubix-py
16+
17+
18+
Architecture
19+
============
20+
21+
The architecture of ``rubix-py`` is pretty straightforward. It consists of the following classes:
22+
23+
- ``RubixClient``: Responsible for connection to Rubix Blockchain Node
24+
- ``Signer``: Signs and performs Blockchain transactions and manages user's crypto keys.
25+
- ``Querier``: Queries information such as Token Balances, Smart Contract and NFT token chains, etc.
26+
27+
``RubixClient`` has a set of internal methods to make API requests to the node. Both ``Signer`` and ``Querier`` consumes an instance of ``RubixClient`` which helps them to achieve their respective operations with the Blockchain node.
28+
29+
Let's have a look at a simple example of fetching RBT balance and transferring them:
30+
31+
.. code-block:: python
32+
33+
from rubix.client import RubixClient
34+
from rubix.signer import Signer
35+
from rubix.querier import Querier
36+
37+
# Define the RubixClient by specifying the target Rubix node address
38+
# and optionally providing timeout in seconds
39+
client = RubixClient(node_url="http://localhost:20000", timeout=300)
40+
41+
# Define the Signer
42+
# If you already have a BIP-39 24-word mnemonic, you can pass it to the Signer
43+
# Else, a random mnemonic will be used
44+
signer = Signer(
45+
rubixClient=client,
46+
mnemonic="<Enter 24-word long BIP-39 mnemonic>" # This can be left empty
47+
)
48+
49+
# Internally, a call is made to Rubix Node to create and register your DID
50+
user_did = signer.did
51+
52+
# Retrieve the keypair which can be used for signing arbitrary message
53+
keypair = signer.get_keypair()
54+
55+
# Retrieve the mnemonic
56+
mnemonic = signer.get_mnemonic()
57+
58+
# Define the Querier
59+
queryClient = Querier(
60+
rubixClient=client
61+
)
62+
63+
# Check RBT balance
64+
balance_info = queryClient.get_rbt_balance(user_did)
65+
balance = balance_info["rbt"]
66+
67+
# Perform RBT Transfer
68+
tx_response = signer.send_rbt_tokens(
69+
receiver_did="<Enter recipient DID>",
70+
rbt_amount=0.001,
71+
comment="Test RBT Transfer"
72+
)
73+
74+
if tx_response["status"] is True:
75+
print("RBT Transfer Successful!")
76+
else:
77+
print("RBT Transfer Failed!: ", tx_response.get("message", ""))
78+
79+
80+
Usage
81+
=====
82+
83+
Refer `examples <https://github.com/your-org/rubix-py/tree/main/examples>`_ for more usecases

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ version = "0.1.0"
88
description = "Rubix Client SDK for Python"
99
requires-python = ">=3.10"
1010
license = { text = "MIT" }
11+
readme = "docs/readme.rst"
1112
authors = [
1213
{ name = "Arnab Ghose", email = "arnab.g@rubix.net" }
1314
]

0 commit comments

Comments
 (0)