Skip to main content

MST Blockchain SDK (Python)

A modular and lightweight blockchain development kit for interacting with any MST-compatible network. This is a Python port of the MST Blockchain SDK (JS), built on web3.py and eth-account, providing the same easy-to-use abstractions for providers, signers, and contract interactions.

Table of Contents

Features

  • Client Orchestration: Universal entry point for all SDK features.
  • Provider Management: Simple JSON-RPC provider (via web3.py) for fetching block data and account state.
  • Secure Signing: Integrated Signer using eth-account for secure transaction signing and address management.
  • Balances: Built-in utilities for checking native token balances.
  • Network Selection: Pick "mainnet" or "testnet" and the SDK resolves the correct RPC endpoint for you — no config files or env vars needed.

Installation

pip install -r requirements.txt

For local development (so the blockchain_sdk package resolves from src/), install it in editable mode:

pip install -e .

(Recommended: do this inside a virtual environment — python -m venv .venv then activate it — before installing.)

There is no .env file or environment configuration to set up. The network is selected by name at runtime, and the private key is passed directly wherever you construct a Client — both are plain user input, not config.

Quick Start

1. Initialize the Client

from blockchain_sdk import Client

private_key = "0x..."

client = Client("testnet", private_key)   # or "mainnet"

2. Generate a Random Wallet

# Creates a new client with a fresh random private key
client = Client.create_random("testnet")
print(f"Generated Address: {client.signer.address}")
print(f"Private Key: {client.signer.get_private_key()}")

3. Check Account Balance (via Provider)

address = "0x..."
# Access balance through the provider
balance = client.provider.get_balance(address)
print(f"Address Balance: {balance} wei")

4. Estimate Gas & Send Transactions

to_address = "0x..."
amount = "1000000000000000000"  # 1 TOKEN

# 1. Estimate gas first
gas_limit = client.signer.estimate_gas("sendNative", [to_address, amount])
print(f"Estimated Gas: {gas_limit}")

# 2. Send the transaction
tx_hash = client.signer.send_native(to_address, amount)
print(f"Transaction Hash: {tx_hash}")

5. Deploy Contract & Get Address

abi = [...]
bytecode = "0x..."
args = ["InitialValue"]

# 1. Start deployment
tx_hash = client.signer.deploy(abi, bytecode, args)
print(f"Deployment Hash: {tx_hash}")

# 2. Wait for it to be mined
receipt = client.provider.wait_for_transaction(tx_hash)

# 3. Get the new contract address
print(f"Contract Deployed at: {receipt.contractAddress}")

Networks

Client resolves its RPC endpoint from a network name (defined in blockchain_sdk.utils.constants.NETWORKS):

Network RPC URL
testnet (default) https://testnetrpc.mstblockchain.com
mainnet https://mariorpc.mstblockchain.com/
from blockchain_sdk import Client

testnet_client = Client("testnet", private_key)
mainnet_client = Client("mainnet", private_key)

Passing an unrecognized network name raises a ValueError.

Core Modules

1. Client

The root container and main entry point.

  • Client(network="testnet", private_key=None): Resolves the RPC URL for network and constructs the Provider/Signer.
  • Client.create_random(network="testnet"): Returns a new Client instance with a random signer.
  • provider: Instance of Provider.
  • signer: Instance of Signer (if private_key provided).

2. Provider (Read-only)

Accessed via client.provider.

  • get_block_number(): Returns the latest block.
  • get_balance(address): Fetches raw balance.
  • get_transaction_receipt(tx_hash): Fetches the receipt of a mined txn.
  • wait_for_transaction(tx_hash): Waits for a txn to be mined.
  • estimate_gas(transaction): Estimates gas for a raw transaction object.

3. Signer (Identity & Writing)

Accessed via client.signer.

  • Signer.create_random(provider): Generates a new random Signer attached to a provider.
  • get_private_key(): Returns the private key of the current wallet.
  • estimate_gas(method, args): Estimates gas for Signer methods (sendNative, sendToken, deploy).
  • send_transaction(tx): Signs and broadcasts any transaction.
  • send_native(to, amount): Shortcut for sending native tokens.
  • send_token(token_address, to, amount): Sends ERC20 tokens.
  • deploy(abi, bytecode, args=None): Deploys smart contracts.
  • get_address(): Returns the signer's public address.

4. Errors

Custom error classes for better debugging (blockchain_sdk.Errors).

  • ProviderError: Network or RPC issues.
  • TransactionError: Validation or on-chain submission failures.
  • WalletError: Private key or signer initialization issues.

Testing

Run the test suite to ensure everything is configured correctly:

pytest

License

MIT

Download files

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

Source Distribution

mst_sdk_python-1.0.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

mst_sdk_python-1.0.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file mst_sdk_python-1.0.0.tar.gz.

File metadata

  • Download URL: mst_sdk_python-1.0.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mst_sdk_python-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ea187dc89f1483ae0f1d9c9318e540700cc07e03b607889ab5f70e40d6319171
MD5 40721c3d67f530f4ac6b07ed8ddd0110
BLAKE2b-256 66aec00849823456d723b441ec6eee67991035ba95e058f2ace07432ef3df7db

See more details on using hashes here.

Provenance

The following attestation bundles were made for mst_sdk_python-1.0.0.tar.gz:

Publisher: workflow.yml on Masterstroke-technosoft/mst-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mst_sdk_python-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mst_sdk_python-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mst_sdk_python-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ea0c3f463c53ef78df102048ee12fcd70daa1a1d311d48d26ef2d8ad3d29dbb
MD5 33f9e053aa84898aee81c558975836bf
BLAKE2b-256 a7f14fe7ae8413699c9a0eaaf94ae1556d88d46cdb76052220145149f1ce57ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for mst_sdk_python-1.0.0-py3-none-any.whl:

Publisher: workflow.yml on Masterstroke-technosoft/mst-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.0.1

2 files

This release

1.0.0 This release

2 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