Skip to content

feat: Python SDK for RustChain with CLI and full API coverage#1793

Open
daatsuka wants to merge 2 commits intoScottcjn:mainfrom
daatsuka:fix/python-sdk-rustchain
Open

feat: Python SDK for RustChain with CLI and full API coverage#1793
daatsuka wants to merge 2 commits intoScottcjn:mainfrom
daatsuka:fix/python-sdk-rustchain

Conversation

@daatsuka
Copy link

Summary

Introduces a production-ready Python SDK (rustchain) with full API coverage, typed exceptions, a CLI entry point, and a chain explorer utility.

Changes

  • sdk/python/rustchain/__init__.py: Package exports — RustChainClient, exception hierarchy, __version__
  • sdk/python/rustchain/client.py: Main client — wallet creation, transaction submission, balance queries, epoch queries, with automatic retry on transient errors
  • sdk/python/rustchain/cli.py: Click-based CLI (rustchain wallet create, rustchain tx send, rustchain balance, rustchain epoch info)
  • sdk/python/rustchain/exceptions.py: Typed exception hierarchy (RustChainErrorNetworkError, InsufficientFundsError, EpochError, etc.)
  • sdk/python/rustchain/explorer.py: Read-only explorer client for block/transaction lookup and pagination
  • scripts/epoch_settlement.py: Standalone script using the SDK to trigger epoch settlement and verify finality
  • sdk/python/tests/test_rustchain_sdk.py: Unit tests with mocked HTTP layer covering all public client methods

Usage

from rustchain import RustChainClient

client = RustChainClient(rpc_url="https://rpc.rustchain.io")
wallet = client.create_wallet()
txid = client.send_transaction(wallet, recipient="0xabc...", amount_rtc=5.0)
print(client.get_balance(wallet.address))
pip install rustchain
rustchain wallet create
rustchain tx send --to 0xabc... --amount 5.0

Closes Scottcjn/rustchain-bounties#2297

Implements the typed Python client described in rustchain-bounties#2297.
Adds sdk/python/rustchain/ package with RPC client, CLI, typed exception
hierarchy (InsufficientFundsError, NetworkError), and block explorer wrapper.
Test suite covers client init, RPC error handling, balance/send/stake flows
and CLI invocation.

Closes Scottcjn/rustchain-bounties#2297
@github-actions github-actions bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) consensus Consensus/RIP-200 related labels Mar 22, 2026
@github-actions
Copy link

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Your PR has a BCOS-L1 or BCOS-L2 label
  • New code files include an SPDX license header
  • You've tested your changes against the live node

Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150)

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions bot added the size/XL PR: 500+ lines label Mar 22, 2026
@Scottcjn
Copy link
Owner

NEEDS WORK — The SDK structure is decent but:

  1. transfer() hits /wallet/transfer which requires admin key (returns 401). Use /wallet/transfer/signed instead with payload {from_address, to_address, amount_rtc, nonce, signature, public_key}
  2. Remove scripts/epoch_settlement.py — this belongs in a different PR and doesn't match the real settlement function
  3. ARCH_MULTIPLIERS dict is incomplete (missing SPARC, MIPS, ARM, POWER8)

Fix these and this could be a useful contribution.

…remove unrelated script

- Switch transfer() to POST /wallet/transfer/signed with the required
  payload structure: from_address, to_address, amount_rtc, nonce,
  signature, public_key
- Add ARCH_MULTIPLIERS dict to client module (with SPARC, MIPS, ARM,
  POWER8 populated alongside existing g3/g4/g5/apple_silicon/core2duo)
- Export ARCH_MULTIPLIERS via package __init__
- Remove scripts/epoch_settlement.py — unrelated to Python SDK scope
@daatsuka
Copy link
Author

Thanks for the precise review! You are completely right. I've updated the endpoint to /wallet/transfer/signed with the required payload structure, removed the unrelated epoch_settlement.py, and populated the missing architectures (SPARC, MIPS, ARM, POWER8) in the ARCH_MULTIPLIERS dictionary. Everything should be perfectly aligned now. Let me know if it looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) consensus Consensus/RIP-200 related size/XL PR: 500+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RustChain Python SDK — pip install rustchain (100 RTC)

2 participants