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 1.2.1

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 1.2.1
File Size Uploaded
rubix_py-1.2.1.tar.gz 21.4 kB Details

Built distribution (wheel)

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

Total release size: 42.7 kB

Release files / rubix_py-1.2.1.tar.gz

Download URL rubix_py-1.2.1.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ccc8906623da3e89cd76ac0543ba27eb795354b2ba19658278d6de3027d3e148
BLAKE2b-256 checksum
How to use checksums
5fdf3980cf753e948ac66b511ddb931278db0db807487cea63faced97ab033e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

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

Download URL rubix_py-1.2.1-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c050c62be2abd558f400120e3714d851fd39d6d8356dae5356b1f6ae8402a690
BLAKE2b-256 checksum
How to use checksums
85cd59ebc743932598450ad52fecd9604ff2d49d7fe3a77b242453f5e2467ade
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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