Create an Account¶
Introduction¶
Creating accounts is a fundamental operation when building applications on Polkadot SDK-based chains. Accounts serve as the basis for identity, asset ownership, and transaction signing. Generating and managing accounts programmatically enables you to build wallets, automate operations, and create smoother user experiences.
Polkadot SDK-based chains use the SR25519 signature scheme by default, though ED25519 and ECDSA are also supported. Each account consists of a public key (address) and a private key (seed or mnemonic). Keep your private keys secure and never share them.
This tutorial generates an account in Rust with sp-core, the Polkadot SDK crate that provides the core cryptographic primitives. To sign transactions with the generated mnemonic, use subxt-signer, as shown in Send Transactions with SDKs.
Account generation is also available in third-party libraries, for example Polkadot.js API and Python Substrate Interface.
Prerequisites¶
Before starting, make sure you have:
- A basic understanding of public-key cryptography concepts.
- Rust toolchain (latest stable) and Cargo.
Generate an Account in Rust¶
-
Create a new Rust project:
-
Add
sp-coreas a dependency: -
Create your account generation code in
src/main.rs:src/main.rsuse sp_core::crypto::{Ss58AddressFormat, Ss58Codec}; use sp_core::{sr25519, Pair}; // SS58 address prefix of your target chain (42 is the generic Substrate prefix) const SS58_PREFIX: u16 = 42; fn main() { let (pair, phrase, _) = sr25519::Pair::generate_with_phrase(None); let address = pair .public() .to_ss58check_with_version(Ss58AddressFormat::custom(SS58_PREFIX)); println!("Address: {}", address); println!("Mnemonic: {}", phrase); }Key aspects of the code:
- Keypair generation:
sr25519::Pair::generate_with_phrase()creates a new key pair with a mnemonic. - Public key extraction: The
public()method retrieves the public key from the pair. - SS58 encoding:
to_ss58check_with_version()encodes the public key as a human-readable address using the prefix inSS58_PREFIX. SetSS58_PREFIXto the prefix of your target chain. The example uses42, the generic Substrate prefix.
- Keypair generation:
-
Build and run the project:
You should see output similar to:
cargo run Address: 5DGxJ1ufRFchy6edgzzhBzEWGmbWnY3GLKCFhaxkBcGoC1nq Mnemonic: cushion dog echo people vendor curve truck begin latin romance rebuild ...
Where to Go Next¶
-
Guide Send Transactions with SDKs
Learn how to send signed transactions using Subxt.
-
Guide Calculate Transaction Fees
Learn how to estimate transaction fees before sending transactions from your accounts.
-
Guide Query Chain Data
Query account information, balances, and other chain state.
| Created: November 17, 2026