Skip to main content

Crate aptos_sdk

Crate aptos_sdk 

Source
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:

FeatureDefaultDescription
ed25519YesEd25519 signature scheme
secp256k1YesSecp256k1 ECDSA signatures
secp256r1YesSecp256r1 (P-256) ECDSA signatures
mnemonicYesBIP-39 mnemonic phrase support for key derivation
indexerYesGraphQL indexer client
faucetYesFaucet integration for testnets
blsNoBLS12-381 signatures
keylessNoOIDC-based keyless authentication
macrosNoProc macros for type-safe contract bindings

§Modules

  • account - Account management and key generation
  • crypto - Cryptographic primitives and signature schemes
  • transaction - Transaction building and signing
  • api - REST and GraphQL API clients
  • types - Core Aptos types
  • codegen - Code generation from Move ABIs

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_contractmacros
Generates type-safe contract bindings from an ABI.
aptos_contract_filemacros
Generates contract bindings from an ABI file path.

Structs§

Aptos
The main entry point for the Aptos SDK.

Derive Macros§

MoveStructmacros
Derive macro for Move-compatible struct serialization.