Skip to main content

Python SDK for Miden blockchain

Project description

Miden Python SDK

A Python SDK for interacting with the Miden blockchain, providing a Pythonic interface to Miden's core features without requiring Rust expertise.

Miden License Status

Overview

Miden is a zkRollup secured by Ethereum and the AggLayer, offering privacy, client-side proving, parallel execution, and Turing-complete smart contracts. This SDK provides a Pythonic interface to Miden's core features:

  • Node Communication: Interact with Miden nodes via gRPC
  • Wallet & Account Management: Create and manage private/public and mutable/immutable accounts
  • Transaction Building: Construct and submit transactions
  • STARK Proof Generation: Generate proofs using the Miden CLI
  • Note Management: Create, import, and export private or public notes

Installation

  1. Install the Miden client:
cargo install miden-client
  1. Install the Python SDK:
pip install miden-sdk
  1. Download and place the WASM module:
# Install @demox-labs/miden-sdk
npm install @demox-labs/miden-sdk

# Copy WASM module to SDK directory
cp node_modules/@demox-labs/miden-sdk/dist/miden_sdk.wasm miden_sdk/wasm/

Quick Start

Create a Wallet

from miden_sdk import MidenClient, Wallet

# Initialize client with testnet endpoint
client = MidenClient(rpc_endpoint="http://18.203.155.106:57291")

# Create a private, mutable wallet
wallet = client.new_wallet(storage_mode="private", mutable=True)

# Save wallet to JSON
wallet.save("wallet.json")
print(f"Wallet created: {wallet.account_id}")

Send a Payment

from miden_sdk import MidenClient, Wallet, Transaction, NoteType

# Initialize client
client = MidenClient(rpc_endpoint="http://18.203.155.106:57291")

# Load wallet
wallet = Wallet.load("wallet.json", client=client)

# Create a payment transaction
tx = Transaction.pay_to_id(
    sender=wallet,
    recipient_address="0xABC1234567890...",
    amount=100,
    faucet_id="0xDEF4567890...",
    note_type=NoteType.PRIVATE
)

# Generate STARK proof
tx.generate_proof()

# Submit transaction
tx_id = client.send_transaction(tx)
print(f"Transaction submitted: {tx_id}")

Import a Note

from miden_sdk import MidenClient, Note

# Initialize client
client = MidenClient(rpc_endpoint="http://18.203.155.106:57291")

# Import note from JSON
note = Note.import_note("note.json")

# Add to client's note store
client.add_note(note)
print(f"Note imported: {note.id}")

Project Structure

miden-sdk/
├── miden_sdk/
│   ├── __init__.py
│   ├── client.py        # gRPC and WASM integration
│   ├── wallet.py        # Keypair and account management
│   ├── transaction.py   # Transaction construction
│   ├── note.py          # Note creation and querying
│   ├── config.py        # Constants and configurations
│   ├── utils.py         # Utility functions
├── tests/               # Unit and integration tests
├── examples/            # Example scripts

Requirements

  • Python 3.7+
  • miden-client (Rust)
  • @demox-labs/miden-sdk WASM module

Development

  1. Clone the repository:
git clone https://github.com/chumbacash/miden-sdk.git
cd miden-sdk
  1. Install development dependencies:
pip install -e ".[dev]"
  1. Run tests:
pytest

Features

  • Intuitive API Design: User-friendly interface following Python idioms
  • Clear Error Handling: Custom exceptions with informative messages
  • Type Hinting: Comprehensive type hints for IDE support
  • Modular Architecture: Clean separation of concerns

Status

This SDK is in alpha stage and compatible with Miden Testnet v6 (released February 2025). It will be updated as Miden evolves toward mainnet launch in late 2025.

Resources

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

miden_sdk-0.1.1.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

miden_sdk-0.1.1-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file miden_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: miden_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for miden_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 65989fac03ed3860361b762ba3a7ba0f0a7ccf6f7c7b752f315dbadcd259440e
MD5 477b4d9f4110a10ad5ab762ecafcfec6
BLAKE2b-256 dad7acb3481ff255a35b19454ac2495921ab32c63177c56ad290ecb3ef73891e

See more details on using hashes here.

File details

Details for the file miden_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: miden_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for miden_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 69e0aaadf167ee14cb8bedb3c9230fa1ccffc825fd53ff90d3f561a948c2bfdf
MD5 926236b80a90052d25c6f048e4da90bf
BLAKE2b-256 d6e44ba55f6084cddf3b090db562160c08b11e17f0add650ac5fe2986b23513b

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