This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
The Aptos Rust SDK is a user-friendly, idiomatic Rust SDK for interacting with the Aptos blockchain. It has feature parity with the TypeScript SDK and supports full blockchain interaction including account management, transaction building, and multiple signature schemes.
The project consists of two workspace crates:
- aptos-sdk: Main SDK crate with API clients, account management, transaction building, and cryptography
- aptos-sdk-macros: Procedural macros for type-safe contract bindings
cargo build # Build with default features (ed25519 + secp256k1)
cargo build -p aptos-sdk --all-features # Build with all features
cargo build --release # Release buildcargo test -p aptos-sdk # Run unit tests
cargo test -p aptos-sdk --all-features # Test with all features
cargo test -p aptos-sdk --features "e2e" -- --ignored # E2E tests (requires localnet)cargo clippy -p aptos-sdk --all-features -- -D warnings # Strict linting
cargo fmt # Format code
cargo fmt -- --check # Check formattingcargo run -p aptos-sdk --example transfer --features "ed25519,faucet"
cargo run -p aptos-sdk --example view_function --features "ed25519"Examples are in crates/aptos-sdk/examples/.
The SDK follows a client-centric design with Aptos as the main entry point:
Aptosincrates/aptos-sdk/src/aptos.rs- Primary client combining all API capabilitiesAptosConfigincrates/aptos-sdk/src/config.rs- Network configuration (mainnet, testnet, devnet, localnet)
-
account/- Account management and key generationEd25519Account,Secp256k1Account,Secp256r1Account- Single-key accountsMultiKeyAccount- Multi-key authenticationKeylessAccount- OIDC-based keyless authentication
-
api/- API clientsfullnode.rs- REST API client for fullnode interactionsindexer.rs- GraphQL indexer clientfaucet.rs- Faucet client for testnetsans.rs- Aptos Names Service integration
-
transaction/- Transaction building and signingbuilder.rs- Fluent builder pattern for transactionsauthenticator.rs- Transaction authenticationsponsored.rs- Fee payer (sponsored) transactionsbatch.rs- Transaction batching
-
crypto/- Cryptographic primitives- Multiple signature schemes: Ed25519, Secp256k1, Secp256r1, BLS12-381
hash.rs- Hashing utilitiestraits.rs- Core cryptographic traits
-
types/- Core Aptos typesaddress.rs- Account addressesmove_types.rs- Move type representationshash.rs- Hash values
-
codegen/- Code generation from Move ABIs- Generates type-safe Rust bindings from Move contract ABIs
- Feature Flags: Cryptographic schemes and optional features are behind feature flags (ed25519, secp256k1, mnemonic, secp256r1, bls, keyless, indexer, faucet)
- Builder Pattern: Transactions and configurations use fluent builder patterns
- Async/Await: Heavy use of
tokiofor async operations - Result Types: Uses
AptosResult<T>withAptosErrorthroughout - BCS Serialization: Uses
aptos-bcscrate for Binary Canonical Serialization
crates/aptos-sdk/src/aptos.rs- Main SDK client combining all capabilitiescrates/aptos-sdk/src/config.rs- Network configurationcrates/aptos-sdk/src/transaction/builder.rs- Transaction buildercrates/aptos-sdk/src/account/mod.rs- Account trait and implementationscrates/aptos-sdk/src/crypto/traits.rs- Core cryptographic traitscrates/aptos-sdk/examples/transfer.rs- Working example of basic transfer
- Version: 1.90+ (specified in
rust-toolchain.toml) - Edition: 2024
- Components: cargo, clippy, rustc, rust-docs, rust-std
- Note: Uses stable rustfmt for formatting
- Unit tests are co-located with source code or in
src/tests/directories - E2E tests require running Aptos localnet (
aptos node run-localnet) - Behavioral tests in
crates/aptos-sdk/tests/behavioral/ - Property-based testing with
proptestfor crypto components (viafuzzingfeature)