Rubix Client SDK for Python
Project description
Rubix Client SDK for Python
rubix-py is a lightweight client for the Rubix Blockchain Node, providing complete node interaction with minimal overhead.
⚠️ This project is currently under active development. API changes and method signature updates may occur between releases. Please review the Release Notes before upgrading.
Installation
Run the following to install rubix-py
pip install rubix-py
Architecture
The architecture of rubix-py is pretty straightforward. It consists of the following classes:
RubixClient: Responsible for connection to Rubix Blockchain Node
Signer: Signs and performs Blockchain transactions and manages user’s crypto keys.
Querier: Queries information such as Token Balances, Smart Contract and NFT token chains, etc.
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.
Let’s have a look at a simple example of fetching RBT balance and transferring them:
from rubix.client import RubixClient
from rubix.signer import Signer
from rubix.querier import Querier
# Define the RubixClient by specifying the target Rubix node address
# and optionally providing timeout in seconds
client = RubixClient(node_url="http://localhost:20000", timeout=300)
# Define the Signer
# If you already have a BIP-39 24-word mnemonic, you can pass it to the Signer
# Else, a random mnemonic will be used
signer = Signer(
rubixClient=client,
mnemonic="<Enter 24-word long BIP-39 mnemonic>" # This can be left empty
)
# Internally, a call is made to Rubix Node to create and register your DID
user_did = signer.did
# Retrieve the keypair which can be used for signing arbitrary message
keypair = signer.get_keypair()
# Retrieve the mnemonic
mnemonic = signer.get_mnemonic()
# Define the Querier
queryClient = Querier(
rubixClient=client
)
# Check RBT balance
balance_info = queryClient.get_rbt_balance(user_did)
balance = balance_info["rbt"]
# Perform RBT Transfer
tx_response = signer.send_rbt_tokens(
receiver_did="<Enter recipient DID>",
rbt_amount=0.001,
comment="Test RBT Transfer"
)
if tx_response["status"] is True:
print("RBT Transfer Successful!")
else:
print("RBT Transfer Failed!: ", tx_response.get("message", ""))
Usage
Refer examples for more usecases
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 rubix_py-0.4.0.tar.gz.
File metadata
- Download URL: rubix_py-0.4.0.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a3e7e0ce89b42e12c8ed7008477f4971e45047eb4e63118801b058c0185f4aa
|
|
| MD5 |
482c8970b8fed9c3346926456b328810
|
|
| BLAKE2b-256 |
e91d33d885832b5ec92917fe66b221ded5137fd925f014e44a3f6680ff0afc8b
|
File details
Details for the file rubix_py-0.4.0-py3-none-any.whl.
File metadata
- Download URL: rubix_py-0.4.0-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bb8e03fb9101df216654920493781c37df4cb62089e20058d3b185158d51b97
|
|
| MD5 |
40360c3ed125111196d6643352c9f211
|
|
| BLAKE2b-256 |
cbeeba4f08748b18a23ea970dfdc697a98ed076c3209c6ccb8eece8900ea7282
|