Skip to main content
The Cosmos SDK uses the Bech32 address format for all user-facing addresses. Bech32 encoding provides robust integrity checks through checksums and includes a human-readable prefix (HRP) that provides contextual information about the address type.

Address Types

The SDK defines three distinct address types, each with its own Bech32 prefix: Each address type also has a corresponding public key prefix:
  • Account public keys: cosmospub
  • Validator public keys: cosmosvaloperpub
  • Consensus public keys: cosmosvalconspub

Supported Key Schemes

The Cosmos SDK supports three key schemes. The choice of scheme affects address length and whether it can be used for transactions or consensus: secp256k1 is the default for user accounts. secp256r1 is supported as an alternative and produces longer addresses (32 bytes). tm-ed25519 is used exclusively for validator consensus keys and does not produce a user-facing address.

Address Derivation

Addresses are derived from public keys through cryptographic hashing. The process differs based on the key algorithm:

Secp256k1 Keys (Account Addresses)

Account addresses use Bitcoin-style address derivation:
Implementation: crypto/keys/secp256k1/secp256k1.go

Ed25519 Keys (Consensus Addresses)

Consensus addresses use truncated SHA-256:
Implementation: crypto/keys/ed25519/ed25519.go

Bech32 Encoding Process

Once address bytes are derived, they’re converted to Bech32 format: Step 1: Convert from 8-bit to 5-bit encoding
Step 2: Encode with Human-Readable Prefix
Implementation: types/bech32/bech32.go

Configuring Bech32 prefixes

Every Cosmos SDK application sets its Bech32 prefixes and SLIP-44 coin type once at startup via sdk.GetConfig(), then seals the config so it cannot be changed at runtime. The defaults (cosmos, cosmosvaloper, etc.) are defined in types/config.go. Chain developers override them before the app starts:

Address Validation

The SDK validates addresses through:
  1. Format validation: Ensures valid Bech32 encoding
  2. Prefix validation: Confirms correct HRP for address type
  3. Length validation: Verifies address is exactly 20 bytes when decoded

Module Addresses

Module accounts use deterministic address derivation defined in ADR-028:
Module addresses are longer (32 bytes vs 20 bytes) to reduce collision probability.

Validator Address Relationships

A validator has three related addresses:
  1. Operator Address (cosmosvaloper1...): The validator’s operational identity, derived from the operator’s account key
  2. Consensus Address (cosmosvalcons1...): Derived from the validator’s consensus public key (Ed25519), used for block signing
  3. Account Address (cosmos1...): The operator’s account for receiving rewards

Performance: Address Caching

The SDK caches Bech32-encoded addresses to optimize repeated conversions:
When Address.String() is called, the SDK:
  1. Checks the LRU cache for the encoded address
  2. Returns cached value if found
  3. Otherwise, performs Bech32 encoding and caches the result
This significantly improves performance during block processing and state queries.

Complete Example

Here’s the full pipeline for creating an account address:
  • Accounts - Understanding account types and management
  • Store - How addresses are used as keys in state storage
  • Transactions - How addresses are used in transaction signing