Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rubix_py-0.3.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rubix_py-0.3.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file rubix_py-0.3.0.tar.gz.

File metadata

  • Download URL: rubix_py-0.3.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for rubix_py-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e15f0b770e5bc188df6e8d8f8ea58c82b46335c108cdef1b4b96f06e7f76d368
MD5 d9eb15ac061aa11f54454cf4a2457719
BLAKE2b-256 cb362bf845a0ca69e2d5a1ed83c2294d3192c0777e5b7dacc6c87de74ea565e2

See more details on using hashes here.

File details

Details for the file rubix_py-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: rubix_py-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for rubix_py-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67e9679d8240723f3ce9dedea768e9dbabcdffb0fab05db9d56d59c08bb879fb
MD5 f451838d3f1f78b663a9bc358c400220
BLAKE2b-256 058c9f65a45bef1965f85d861dc32bae9a650d9e5b22a55821aa28b9f7600f93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page