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
Signerusingeth-accountfor 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 mst_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 mst_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 mst_blockchain_sdk.utils.constants.NETWORKS):
| Network | RPC URL |
|---|---|
testnet (default) |
https://testnetrpc.mstblockchain.com |
mainnet |
https://mariorpc.mstblockchain.com/ |
from mst_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 fornetworkand constructs theProvider/Signer.Client.create_random(network="testnet"): Returns a newClientinstance with a random signer.provider: Instance ofProvider.signer: Instance ofSigner(ifprivate_keyprovided).
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 randomSignerattached 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 (mst_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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mst_sdk_python-1.0.1.tar.gz.
File metadata
- Download URL: mst_sdk_python-1.0.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b4fcd1b698c06613a8181f0feef01a9456dfad44981b772ef8fa82ce04fcd12
|
|
| MD5 |
dfdb7a230644831b361c4e84ae832fe8
|
|
| BLAKE2b-256 |
22199ab8a93385e6806998c35b510b8721ee2bd856ab1ef96ce479a5ad2a650b
|
Provenance
The following attestation bundles were made for mst_sdk_python-1.0.1.tar.gz:
Publisher:
workflow.yml on Masterstroke-technosoft/mst-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mst_sdk_python-1.0.1.tar.gz -
Subject digest:
8b4fcd1b698c06613a8181f0feef01a9456dfad44981b772ef8fa82ce04fcd12 - Sigstore transparency entry: 2580062429
- Sigstore integration time:
-
Permalink:
Masterstroke-technosoft/mst-sdk-python@7ab63d64d87d695607591120f2b162ffcba1fe28 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Masterstroke-technosoft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@7ab63d64d87d695607591120f2b162ffcba1fe28 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mst_sdk_python-1.0.1-py3-none-any.whl.
File metadata
- Download URL: mst_sdk_python-1.0.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96c267f730ea083a64d22499be37267b4dfa0b000cdbb54497795f2819b98c10
|
|
| MD5 |
cbf2a87b63de5b930ca7e546d98561b1
|
|
| BLAKE2b-256 |
9fbf6f40f12cbac7b1bb36b878410b26ce31d228da8828737380a9549672ac5d
|
Provenance
The following attestation bundles were made for mst_sdk_python-1.0.1-py3-none-any.whl:
Publisher:
workflow.yml on Masterstroke-technosoft/mst-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mst_sdk_python-1.0.1-py3-none-any.whl -
Subject digest:
96c267f730ea083a64d22499be37267b4dfa0b000cdbb54497795f2819b98c10 - Sigstore transparency entry: 2580062440
- Sigstore integration time:
-
Permalink:
Masterstroke-technosoft/mst-sdk-python@7ab63d64d87d695607591120f2b162ffcba1fe28 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Masterstroke-technosoft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@7ab63d64d87d695607591120f2b162ffcba1fe28 -
Trigger Event:
push
-
Statement type: