Expand description
§Aptos Rust SDK v2
A user-friendly, idiomatic Rust SDK for the Aptos blockchain.
This SDK provides a complete interface for interacting with the Aptos blockchain, including account management, transaction building and signing, and API clients for both the fullnode REST API and the indexer GraphQL API.
§Quick Start
ⓘ
use aptos_sdk::{Aptos, AptosConfig};
use aptos_sdk::account::{Account, Ed25519Account};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Connect to testnet
let aptos = Aptos::new(AptosConfig::testnet())?;
// Create a new account
let account = Ed25519Account::generate();
println!("Address: {}", account.address());
// Get balance (after funding)
let balance = aptos.get_balance(account.address()).await?;
println!("Balance: {} octas", balance);
Ok(())
}§Feature Flags
The SDK uses feature flags to allow you to include only the functionality you need:
| Feature | Default | Description |
|---|---|---|
ed25519 | Yes | Ed25519 signature scheme |
secp256k1 | Yes | Secp256k1 ECDSA signatures |
secp256r1 | Yes | Secp256r1 (P-256) ECDSA signatures |
mnemonic | Yes | BIP-39 mnemonic phrase support for key derivation |
indexer | Yes | GraphQL indexer client |
faucet | Yes | Faucet integration for testnets |
bls | No | BLS12-381 signatures |
keyless | No | OIDC-based keyless authentication |
macros | No | Proc macros for type-safe contract bindings |
§Modules
Re-exports§
pub use config::AptosConfig;pub use error::AptosError;pub use error::AptosResult;pub use types::AccountAddress;pub use types::ChainId;pub use types::HashValue;
Modules§
- account
- Account management for the Aptos SDK.
- api
- API clients for the Aptos blockchain.
- codegen
- Code generation for Move modules.
- config
- Network configuration for the Aptos SDK.
- crypto
- Cryptographic primitives for the Aptos SDK.
- error
- Error types for the Aptos SDK.
- retry
- Automatic retry with exponential backoff.
- transaction
- Transaction building and signing.
- types
- Core Aptos types.
Macros§
- aptos_
contract macros - Generates type-safe contract bindings from an ABI.
- aptos_
contract_ file macros - Generates contract bindings from an ABI file path.
Structs§
- Aptos
- The main entry point for the Aptos SDK.
Derive Macros§
- Move
Struct macros - Derive macro for Move-compatible struct serialization.