Skip to main content

Module account

Module account 

Source
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 modern SingleKey format
  • MultiEd25519Account - M-of-N multi-signature Ed25519 account
  • Secp256k1Account - Single-key Secp256k1 account (Bitcoin/Ethereum curve)
  • Secp256r1Account - Single-key Secp256r1/P-256 account. Deprecated for transaction signing (off-chain use only): bare secp256r1 signatures are rejected by Aptos validators. Use WebAuthnAccount for 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 (requires secp256r1 feature)
  • 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§

AuthenticationKey
An authentication key used to verify account ownership.
DerivationPathmnemonic
A parsed BIP-32 / BIP-44 derivation path.
Ed25519Accounted25519
An Ed25519 account for signing transactions.
Ed25519SingleKeyAccounted25519
An Ed25519 account using the modern SingleKey authenticator format.
Mnemonicmnemonic
A BIP-39 mnemonic phrase for key derivation.
MultiEd25519Accounted25519
A multi-Ed25519 account supporting M-of-N threshold signatures.
MultiKeyAccount
A multi-key account supporting M-of-N threshold signatures with mixed key types.
PathComponentmnemonic
A single component of a BIP-32 derivation path.
RotationProofChallenge
The challenge signed (by both the current and new keys) to authorize an authentication-key rotation.
Secp256k1Accountsecp256k1
A Secp256k1 ECDSA account for signing transactions.
Secp256r1AccountDeprecatedsecp256r1
A Secp256r1 (P-256) ECDSA account.
WebAuthnAccountsecp256r1
A WebAuthn / Passkey-style account.

Enums§

AnyAccount
An enum over a fixed subset of account types.
AnyPrivateKey
A private key that can be any supported signature scheme.

Constants§

DEFAULT_WEBAUTHN_ORIGINsecp256r1
Default WebAuthn origin field baked into the synthetic client_data_json.origin value. Like rp_id, the on-chain verifier does not enforce a specific value.
DEFAULT_WEBAUTHN_RP_IDsecp256r1
Default WebAuthn relying-party identifier baked into the synthetic authenticator_data.rpIdHash field. 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_key payload that rotates current’s authentication key to new_account’s key.