Skip to content

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

  1. Create a new Rust project:

    cargo new account-creator-rust
    cd account-creator-rust
    
  2. Add sp-core as a dependency:

    cargo add sp-core
    
  3. Create your account generation code in src/main.rs:

    src/main.rs
    use 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 in SS58_PREFIX. Set SS58_PREFIX to the prefix of your target chain. The example uses 42, the generic Substrate prefix.
  4. Build and run the project:

    cargo run
    

    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.

    Get Started

  • Guide Calculate Transaction Fees


    Learn how to estimate transaction fees before sending transactions from your accounts.

    Get Started

  • Guide Query Chain Data


    Query account information, balances, and other chain state.

    Get Started

Last update: November 17, 2026
| Created: November 17, 2026