aptos_sdk/lib.rs
1//! # Aptos Rust SDK v2
2//!
3//! A user-friendly, idiomatic Rust SDK for the Aptos blockchain.
4//!
5//! This SDK provides a complete interface for interacting with the Aptos blockchain,
6//! including account management, transaction building and signing, and API clients
7//! for both the fullnode REST API and the indexer GraphQL API.
8//!
9//! ## Quick Start
10//!
11//! ```rust,ignore
12//! use aptos_sdk::{Aptos, AptosConfig};
13//! use aptos_sdk::account::{Account, Ed25519Account};
14//!
15//! #[tokio::main]
16//! async fn main() -> anyhow::Result<()> {
17//! // Connect to testnet
18//! let aptos = Aptos::new(AptosConfig::testnet())?;
19//!
20//! // Create a new account
21//! let account = Ed25519Account::generate();
22//! println!("Address: {}", account.address());
23//!
24//! // Get balance (after funding)
25//! let balance = aptos.get_balance(account.address()).await?;
26//! println!("Balance: {} octas", balance);
27//!
28//! Ok(())
29//! }
30//! ```
31//!
32//! ## Feature Flags
33//!
34//! The SDK uses feature flags to allow you to include only the functionality you need:
35//!
36//! | Feature | Default | Description |
37//! |---------|---------|-------------|
38//! | `ed25519` | Yes | Ed25519 signature scheme |
39//! | `secp256k1` | Yes | Secp256k1 ECDSA signatures |
40//! | `secp256r1` | Yes | Secp256r1 (P-256) ECDSA signatures |
41//! | `mnemonic` | Yes | BIP-39 mnemonic phrase support for key derivation |
42//! | `indexer` | Yes | GraphQL indexer client |
43//! | `faucet` | Yes | Faucet integration for testnets |
44//! | `bls` | No | BLS12-381 signatures |
45//! | `keyless` | No | OIDC-based keyless authentication |
46//! | `macros` | No | Proc macros for type-safe contract bindings |
47//!
48//! ## Modules
49//!
50//! - [`account`] - Account management and key generation
51//! - [`crypto`] - Cryptographic primitives and signature schemes
52//! - [`transaction`] - Transaction building and signing
53//! - [`api`] - REST and GraphQL API clients
54//! - [`types`] - Core Aptos types
55//! - [`codegen`] - Code generation from Move ABIs
56
57#![cfg_attr(docsrs, feature(doc_cfg))]
58#![forbid(unsafe_code)]
59#![warn(
60 missing_docs,
61 missing_debug_implementations,
62 rust_2018_idioms,
63 unreachable_pub,
64 clippy::pedantic
65)]
66// Pedantic lint exceptions - these are intentionally allowed
67#![allow(
68 clippy::must_use_candidate, // Too noisy for SDK functions
69 clippy::match_same_arms, // Sometimes intentionally explicit for clarity TODO: Remove, this showed a couple of issues
70)]
71
72pub mod account;
73pub mod api;
74pub mod codegen;
75pub mod config;
76pub mod crypto;
77pub mod error;
78pub mod retry;
79pub mod transaction;
80pub mod types;
81
82mod aptos;
83
84// Re-export main entry points
85pub use aptos::Aptos;
86pub use config::AptosConfig;
87pub use error::{AptosError, AptosResult};
88
89// Re-export commonly used types
90pub use types::{AccountAddress, ChainId, HashValue};
91
92// Re-export proc macros when the feature is enabled
93#[cfg(feature = "macros")]
94#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
95pub use aptos_sdk_macros::{MoveStruct, aptos_contract, aptos_contract_file};
96
97// Re-export aptos_bcs for use by the MoveStruct derive macro
98// This allows downstream users to use the derive macro without adding aptos-bcs as a dependency
99#[doc(hidden)]
100pub use aptos_bcs;
101
102#[cfg(test)]
103mod tests;