Mina Rust SDK
Rust SDK for interacting with Mina Protocol nodes via GraphQL.
Features
- Async GraphQL client — query node status, accounts, blocks; send payments and delegations
- Typed response structs with
Currencyarithmetic - Automatic retry with configurable backoff
- Public
execute_query()for custom GraphQL queries tracinginstrumentation
Requirements
- Rust 1.70+ (edition 2021)
- A running Mina daemon with GraphQL enabled
Installation
[]
= "0.1"
Quick Start
use ;
async
Configuration
use ;
use Duration;
let client = with_config;
API Reference
Full API documentation is available on docs.rs.
Queries
| Method | Description |
|---|---|
get_sync_status() |
Node sync status (Synced, Bootstrap, etc.) |
get_daemon_status() |
Comprehensive daemon status |
get_network_id() |
Network identifier |
get_account(public_key, token_id) |
Account balance, nonce, delegate |
get_best_chain(max_length) |
Recent blocks from best chain |
get_peers() |
Connected peers |
get_pooled_user_commands(public_key) |
Pending transactions |
execute_query(query, variables, name) |
Run a custom GraphQL query |
Mutations
| Method | Description |
|---|---|
send_payment(sender, receiver, amount, fee, memo, nonce) |
Send a payment |
send_delegation(sender, delegate_to, fee, memo, nonce) |
Delegate stake |
set_snark_worker(public_key) |
Set/unset SNARK worker |
set_snark_work_fee(fee) |
Set SNARK work fee |
Currency
use Currency;
let a = from_mina?; // 10 MINA
let b = from_mina?; // 1.5 MINA
let c = from_nanomina; // 1 MINA
let d = from_graphql?; // from GraphQL response
println!; // 11.500000000
println!; // 10000000000
assert!;
Development
Integration tests
Integration tests run against a live Mina node and are skipped by default. To run them locally with a lightnet Docker container:
# Wait for the network to sync, then:
MINA_GRAPHQL_URI=http://127.0.0.1:8080/graphql \
Troubleshooting
Connection refused — Make sure the Mina daemon is running and the GraphQL endpoint is accessible. The default URI is http://127.0.0.1:3085/graphql.
Account not found — The account may not exist on the network, or the public key format is incorrect. Mina public keys start with B62q.
Schema drift — If queries fail with unexpected GraphQL errors, the daemon version may have changed its schema. Run the schema drift check: python3 scripts/check_schema_drift.py --endpoint http://your-node:3085/graphql
Timeout errors — Increase the timeout and retry settings via ClientConfig. Some queries (like get_best_chain) can be slow on nodes that are still syncing.
Contributing
Contributions are welcome. Please open an issue first to discuss what you'd like to change.