esp_solana/lib.rs
1//! `no_std` Solana SDK for ESP32 microcontrollers.
2//!
3//! Wallet creation (BIP39/SLIP-10), Ed25519 signing, transaction building,
4//! and JSON-RPC — all in ~163KB of flash on ESP32-C3.
5//!
6//! # Quick start
7//!
8//! ```toml
9//! [dependencies]
10//! esp-solana = { version = "0.1", features = ["wallet"] }
11//! ```
12//!
13//! ```rust,ignore
14//! use esp_solana::prelude::*;
15//! use esp_solana::wallet::Wallet;
16//! use esp_solana::instruction::system_transfer;
17//! use esp_solana::message::Message;
18//! use esp_solana::transaction::Transaction;
19//!
20//! let wallet = Wallet::generate_12(&entropy).unwrap();
21//! let keypair = wallet.keypair(0).unwrap();
22//!
23//! let ix = system_transfer(keypair.pubkey(), recipient, 1_000_000);
24//! let msg = Message::compile(keypair.pubkey(), &[ix], blockhash).unwrap();
25//! let tx = Transaction::new(msg, &[&keypair]).unwrap();
26//! let b64 = tx.to_base64();
27//! ```
28//!
29//! # Features
30//!
31//! - **`crypto`** (default) — Ed25519 signing via `ed25519-compact`
32//! - **`wallet`** — BIP39 mnemonic + SLIP-10 key derivation (enables `crypto`)
33//! - **`std`** — enables std for host-side testing
34
35#![no_std]
36#![cfg_attr(docsrs, feature(doc_cfg))]
37
38extern crate alloc;
39
40pub mod types;
41pub mod bs58;
42pub mod b64;
43pub mod instruction;
44pub mod message;
45pub mod transaction;
46pub mod rpc;
47
48#[cfg(feature = "crypto")]
49#[cfg_attr(docsrs, doc(cfg(feature = "crypto")))]
50pub mod crypto;
51
52#[cfg(feature = "wallet")]
53#[cfg_attr(docsrs, doc(cfg(feature = "wallet")))]
54mod wordlist;
55
56#[cfg(feature = "wallet")]
57#[cfg_attr(docsrs, doc(cfg(feature = "wallet")))]
58pub mod bip39;
59
60#[cfg(feature = "wallet")]
61#[cfg_attr(docsrs, doc(cfg(feature = "wallet")))]
62pub mod slip10;
63
64#[cfg(feature = "wallet")]
65#[cfg_attr(docsrs, doc(cfg(feature = "wallet")))]
66pub mod wallet;
67
68/// Curated re-exports for common use.
69/// `use esp_solana::prelude::*;`
70pub mod prelude {
71 pub use crate::types::*;
72 pub use crate::bs58;
73 pub use crate::b64;
74 pub use crate::instruction::*;
75 pub use crate::message::Message;
76 pub use crate::transaction::Transaction;
77 pub use crate::rpc::{RpcClient, SolanaRpc};
78
79 #[cfg(feature = "crypto")]
80 pub use crate::crypto::Keypair;
81
82 #[cfg(feature = "wallet")]
83 pub use crate::wallet::Wallet;
84
85 #[cfg(feature = "wallet")]
86 pub use crate::bip39::Mnemonic;
87}