Mina Python SDK
Python SDK for interacting with Mina Protocol nodes.
Features
- Daemon GraphQL client -- query node status, accounts, blocks; send payments and delegations
- Typed response objects with
Currencyarithmetic - Automatic retry with configurable backoff
- Context manager support for clean resource management
Installation
pip install mina-sdk
For archive database support (coming soon):
pip install mina-sdk[archive]
Quick Start
from mina_sdk import MinaDaemonClient, Currency
with MinaDaemonClient() as client:
# Check sync status
print(client.get_sync_status()) # "SYNCED"
# Query an account
account = client.get_account("B62q...")
print(f"Balance: {account.balance.total} MINA")
# Send a payment
result = client.send_payment(
sender="B62qsender...",
receiver="B62qreceiver...",
amount=Currency("1.5"),
fee=Currency("0.01"),
)
print(f"Tx hash: {result.hash}")
Configuration
client = MinaDaemonClient(
graphql_uri="http://127.0.0.1:3085/graphql", # default
retries=3, # retry failed requests (must be >= 1)
retry_delay=5.0, # seconds between retries (must be >= 0)
timeout=30.0, # HTTP timeout in seconds (must be > 0)
)
API Reference
Queries
| Method | Returns | Description |
|---|---|---|
get_sync_status() |
str |
Node sync status (SYNCED, BOOTSTRAP, etc.) |
get_daemon_status() |
DaemonStatus |
Comprehensive daemon status |
get_network_id() |
str |
Network identifier |
get_account(public_key) |
AccountData |
Account balance, nonce, delegate |
get_best_chain(max_length) |
list[BlockInfo] |
Recent blocks from best chain |
get_peers() |
list[PeerInfo] |
Connected peers |
get_pooled_user_commands(public_key) |
list[dict] |
Pending transactions |
Mutations
| Method | Returns | Description |
|---|---|---|
send_payment(sender, receiver, amount, fee) |
SendPaymentResult |
Send a payment |
send_delegation(sender, delegate_to, fee) |
SendDelegationResult |
Delegate stake |
set_snark_worker(public_key) |
str | None |
Set/unset SNARK worker |
set_snark_work_fee(fee) |
str |
Set SNARK work fee |
Currency
from mina_sdk import Currency
a = Currency(10) # 10 MINA
b = Currency("1.5") # 1.5 MINA
c = Currency.from_nanomina(1_000_000_000) # 1 MINA
print(a + b) # 11.500000000
print(a.nanomina) # 10000000000
print(a > b) # True
print(3 * b) # 4.500000000
Error Handling
from mina_sdk import MinaDaemonClient, GraphQLError, DaemonConnectionError, CurrencyUnderflow
with MinaDaemonClient(retries=3, retry_delay=2.0) as client:
try:
account = client.get_account("B62q...")
except ValueError as e:
# Account not found on ledger
print(f"Account does not exist: {e}")
except GraphQLError as e:
# Daemon returned a GraphQL-level error
print(f"GraphQL error: {e}")
print(f"Raw errors: {e.errors}")
except DaemonConnectionError as e:
# All retry attempts exhausted
print(f"Cannot reach daemon after retries: {e}")
# Currency underflow
from mina_sdk import Currency, CurrencyUnderflow
try:
result = Currency(1) - Currency(2)
except CurrencyUnderflow:
print("Subtraction would result in negative balance")
Data Types
All response types are importable from the top-level package:
from mina_sdk import (
AccountBalance, # total, liquid, locked balances
AccountData, # public_key, nonce, balance, delegate, token_id
BlockInfo, # state_hash, height, slots, creator, tx count
DaemonStatus, # sync_status, chain height, peers, uptime
PeerInfo, # peer_id, host, port
SendPaymentResult, # id, hash, nonce
SendDelegationResult, # id, hash, nonce
)
Development
git clone https://github.com/MinaProtocol/mina-sdk-python.git
cd mina-sdk-python
python3 -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
pytest
Running integration tests
Integration tests require a running Mina daemon:
MINA_GRAPHQL_URI=http://127.0.0.1:3085/graphql \
MINA_TEST_SENDER_KEY=B62q... \
MINA_TEST_RECEIVER_KEY=B62q... \
pytest tests/test_integration.py -v
Troubleshooting
Connection refused / DaemonConnectionError
The daemon is not running or not reachable at the configured URI. Check:
- Is the daemon running? (
mina client status) - Is the GraphQL port open? (default: 3085)
- Is
--insecure-rest-serverset if connecting from a different host?
GraphQLError: field not found
The SDK's queries may be out of sync with the daemon's GraphQL schema. This can happen after a daemon upgrade. Check the schema drift CI for compatibility status.
Account not found
get_account() raises ValueError when the account doesn't exist on the ledger. This is normal for new accounts that haven't received any transactions yet.
License
Apache License 2.0
Metadata
Release files for mina-sdk 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mina_sdk-0.1.1.tar.gz | 48.3 kB | With provenance | Details for mina_sdk-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mina_sdk-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for mina_sdk-0.1.1-py3-none-any.whl |
Total release size: 86.8 kB
Release files / mina_sdk-0.1.1.tar.gz
| Download URL | mina_sdk-0.1.1.tar.gz |
|---|---|
| Size | 48.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7ce2398365e8ffdf1f93efeb12f89c7f381c742fd1e2d8e629f6f5c20df13c8
|
|
BLAKE2b-256 checksum How to use checksums |
ff9bd3e46339a3d76b635f7181e69b36899b94c6322524b3087f268bf0d3fedc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency logRelease files / mina_sdk-0.1.1-py3-none-any.whl
| Download URL | mina_sdk-0.1.1-py3-none-any.whl |
|---|---|
| Size | 38.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aee782184f445cffa06252e770ca456138dc30ec3dffd4c7a0fa4b59676968b7
|
|
BLAKE2b-256 checksum How to use checksums |
12faf5ece650eb9b6b8a347c867b135fced659142dae0a960ebf573f89d13cbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency logSecurity for mina-sdk 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for mina_sdk-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.