Skip to main content

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)

# The Singer class takes two mandatory inputs:
# - rubixClient: Rubix Client instance
# - alias: Alias give to the account holding the cryptographic keypair. It can therefore
# be used everytime user wants to refer to the same keypair present in SDK config. If the
# keypair files are not present, it will be created. The keypair values will then depend on
# whether user passes a mnemonic or not
#
# Optional Arguments:
# - mnemonic: Account can be recovered by passing a 24-word BIP-39 mnemonic. If not passed,
# a random mnemonic is generated.
# - config_path: Directory where files associated with SDK such as keypairs will be stored
signer = Signer(
     rubixClient=client,
     alias="nick",
     mnemonic="<Enter 24-word long BIP-39 mnemonic>",
     config_path="<Config Path for SDK dir>"
 )


# 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

Metadata

Release files for rubix-py 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rubix-py 2.0.0
File Size Uploaded Provenance Actions
rubix_py-2.0.0.tar.gz 22.4 kB Without provenance Details for rubix_py-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rubix-py 2.0.0
File Interpreter ABI Platform Actions
rubix_py-2.0.0-py3-none-any.whl Python 3 none any Details for rubix_py-2.0.0-py3-none-any.whl

Total release size: 44.2 kB

Release files / rubix_py-2.0.0.tar.gz

Download URL rubix_py-2.0.0.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
302df94540b58bdc653794d4dac3fdc62a2e22258114a7344747a41e6ff5cf9c
BLAKE2b-256 checksum
How to use checksums
755918c874ecf658901cc8ecd52d6509320e403889ce3cfbf28b7aad17e664f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / rubix_py-2.0.0-py3-none-any.whl

Download URL rubix_py-2.0.0-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3b427b4d0f5d5e4d74ecdbc49206a8447adcc3074dc838d7f90c898b0d4d840
BLAKE2b-256 checksum
How to use checksums
1629ddcff533ea60137c8e6414178de786295ecbfbf1ab4249df548850710295
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Security for rubix-py 2.0.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page