Wallets & Accounts

circle-info

In Stacks, the terms 'address' and 'principal' are used interchangeably.

Introduction

Stacks wallets are software or hardware tools for storing cryptocurrencies, NFTs, and other digital assets. They are also used for establishing on-chain identity in decentralized applications (dApps). These wallets cryptographically store and manage each user’s identity and funds through a single blockchain address, which leverage public-key cryptography.

Purpose of a Stacks wallet

  • Establish User Identity

  • Store Assets

  • Display Balances

  • Sign Transactions

  • Sign Messages

  • Participate in the Bitcoin Economy

Wallets in Stacks consists of accounts, which uses an accounts-based model, rather than a UTXO model like Bitcoin. This model is simpler than the UTXO model and has a more traditional concept of “balance”, similar to what you would encounter at a bank. In this model, each address has a single “balance” figure for a given token that increases/decreases as transactions are sent to/from that account. This is what most Web3 ecosystems use. In a UTXO model, the network operates as a ledger, with each UTXO being analogous to a cash bill.

Components of a Stacks account

  • Private Key - The private key is an alphanumeric code that is paired to a single public key on a 1:1 basis. Never share your private key with anyone. A private key is how you prove ownership of a public key and how you can spend assets held by that particular key-pair. Example private key in Stacks (32 bytes appended with a 0x01 byte): 5a4133fec2cf923d37238d3ba2fcd2ee9c8dce882c22218fd210d8a02ceb2c7401

  • Public Key - The public key is derived mathematically from the private key. It can be shared safely and is used by the network to verify signatures created by the private key, without revealing the private key itself. Example public key in Stacks (compressed format): 02e8eb87862945d369511fdcce326ffef9a01b68c7d070e3ce685a5cbb9b1ecfc5

  • Address (Principal) - The address is a shorter, user-friendly representation derived from the public key. It’s what you share to receive sBTC, STX, tokens, or NFTs on Stacks, and it acts as the on-chain identifier for the user. Example public address in Stacks (c32check encoding): SPM9G3CNGSCTB4956290NESM0MR9W9CCEPVEPSQC

circle-info

The private/public key generation uses the cryptographic secp256k1 curve.

The cryptographic signature algorithm used in Stacks is ECDSA over secp256k1.

Addresses are created by generating the RIPEMD-160 hash of the SHA256 of the public key. BTC addresses are encoded with Base58Check. For Stacks addresses, c32checkarrow-up-right is used.

Stacks accounts are entities that own assets, like Stacks (STX) tokens. An account has an address, private key, nonce, and one or more asset balances. Assets cannot leave an account without an action from the account owner. All changes to assets (and the balances of the account) require a corresponding transaction.

All Stacks wallets also support Bitcoin addresses, enabling seamless participation across both the Stacks and Bitcoin ecosystems.

Address formats

Stacks addresses use different prefixes to indicate the network they belong to, making it easy to distinguish between mainnet and testnet addresses.


How to create a Stacks account?

A wallet's account are generated from a 24-word mnemonic phrase conforming to the BIP39 standard. This is often referred to as the seed phrase. The seed phrase provides access to Stacks accounts.

triangle-exclamation

There are a few different ways to create a Stacks account as both a developer and non-developer.

1

Using Stacks.js

For programmatic wallet generation or when restoring accounts from backup, you can derive addresses from a mnemonic seed phrase. Each wallet can contain multiple accounts, all derived from the same seed phrase using different derivation paths.

For more ways on programmaticly generating keys and accounts, check out the guide here.

2

Using the Stacks CLI tool

Using the Stacks CLI tool allows you to manage wallets on the command line.

make_keychain

get_address

For more usage examples, check out the Stacks CLI repo herearrow-up-right.

3

Using Bitcoin L2 wallet extensions/apps

There are many popular Bitcoin wallets that support Bitcoin layers and metaprotocols. Leather and Xverse are popular options for getting started with Stacks.

4

Using other community built tools

Check out the Stacks Devtools Catalog for other creative devtools for creating and managing Stacks wallets.


How are Clarity contract addresses formatted?

On Stacks, a contract address/principal uniquely identifies a deployed smart contract and is structured as an account principal plus a contract namespace, forming a unique on-chain identity:

Structure Breakdown

  1. Deployer Address A standard Stacks principal (derived from a hash160 of a public key), such as:

    • SP... → mainnet

    • ST... → testnet

  2. Contract Name An ASCII identifier chosen at deployment time (e.g., my-token, amm-v1, nft-market).

Why It’s Structured This Way

Because contract identifiers are namespaced by the deployer’s address:

  • Two different accounts can deploy contracts with the same name.

  • A single account cannot deploy two contracts with the same name.

  • The identifier is deterministic and globally unique.


Handling different formats

It's common for new Stacks developers to get tripped up on the different ways when specifying Stacks' principals (aka addresses) in their development.

Here's a breakdown of dealing with principals in 3 different use cases.


The Stacks and Bitcoin address connection

What makes Stacks beautifully connected to its L1 settlement layer, Bitcoin, is their many shared aspects. One being how both utilize a similar address generation scheme based on the P2PKH format, which allows for both a Bitcoin & Stacks address to share the same public key hash. If you base58check decode a legacy bitcoin address, you can reveal the public key hash, which can then be used to generate its respective c32check encoded Stacks address.

Programmatically, you could also use a method called b58ToC32, from the c32check javascript library, which can abstract the conversion for you.


Additional Resources

Last updated

Was this helpful?