Expand description
Account management for the Aptos SDK.
This module provides account types that wrap cryptographic keys and provide a unified interface for signing transactions.
§Account Types
Ed25519Account- Single-key Ed25519 account (legacy format, most common)Ed25519SingleKeyAccount- Ed25519 account using modernSingleKeyformatMultiEd25519Account- M-of-N multi-signature Ed25519 accountSecp256k1Account- Single-key Secp256k1 account (Bitcoin/Ethereum curve)Secp256r1Account- Single-key Secp256r1/P-256 account. Deprecated for transaction signing (off-chain use only): baresecp256r1signatures are rejected by Aptos validators. UseWebAuthnAccountfor on-chain P-256 signing.WebAuthnAccount- Secp256r1/P-256 account using the WebAuthn/Passkey envelope; the supported path for signing Aptos transactions with a P-256 key (requiressecp256r1feature)MultiKeyAccount- M-of-N multi-signature account with mixed key types
§Ed25519 example
ⓘ
use aptos_sdk::account::Ed25519Account;
// Generate a new random account
let account = Ed25519Account::generate();
println!("Address: {}", account.address());
// Create from a private key
let private_key_hex = "0x...";
let account = Ed25519Account::from_private_key_hex(private_key_hex).unwrap();Structs§
- Authentication
Key - An authentication key used to verify account ownership.
- Derivation
Path mnemonic - A parsed BIP-32 / BIP-44 derivation path.
- Ed25519
Account ed25519 - An Ed25519 account for signing transactions.
- Ed25519
Single KeyAccount ed25519 - An Ed25519 account using the modern
SingleKeyauthenticator format. - Mnemonic
mnemonic - A BIP-39 mnemonic phrase for key derivation.
- Multi
Ed25519 Account ed25519 - A multi-Ed25519 account supporting M-of-N threshold signatures.
- Multi
KeyAccount - A multi-key account supporting M-of-N threshold signatures with mixed key types.
- Path
Component mnemonic - A single component of a BIP-32 derivation path.
- Rotation
Proof Challenge - The challenge signed (by both the current and new keys) to authorize an authentication-key rotation.
- Secp256k1
Account secp256k1 - A Secp256k1 ECDSA account for signing transactions.
- Secp256r1
Account Deprecated secp256r1 - A
Secp256r1(P-256) ECDSA account. - WebAuthn
Account secp256r1 - A WebAuthn / Passkey-style account.
Enums§
- AnyAccount
- An enum over a fixed subset of account types.
- AnyPrivate
Key - A private key that can be any supported signature scheme.
Constants§
- DEFAULT_
WEBAUTHN_ ORIGIN secp256r1 - Default WebAuthn
originfield baked into the syntheticclient_data_json.originvalue. Likerp_id, the on-chain verifier does not enforce a specific value. - DEFAULT_
WEBAUTHN_ RP_ ID secp256r1 - Default WebAuthn relying-party identifier baked into the synthetic
authenticator_data.rpIdHashfield. The on-chain verifier does not enforce a specific value, so any deterministic 32-byte hash is fine.
Traits§
- Account
- Trait for account types that can sign transactions.
Functions§
- build_
rotate_ auth_ key_ payload - Builds a signed
0x1::account::rotate_authentication_keypayload that rotatescurrent’s authentication key tonew_account’s key.