Accounts

Introduction
Stacks uses an accounts-based model, more similar to Ethereum, rather than a UTXO model like Bitcoin. In a UTXO model, the network operates as a ledger, with each UTXO being analagous to a cash bill.
With an accounts-based model, each account is associated with a balance and that balance can be added to or subtracted from.
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.
Creation
An account is generated from a 24-word mnemonic phrase. This is often referred to as the seed phrase. The seed phrase provides access to Stacks accounts.
If the seed phrase is lost, access to the associated account cannot be restored. No person or organization can recover a lost seed phrase.
The easiest way to generate a new Stacks account is to use the Stacks CLI:
make_keychain creates the following file:
mnemonic
A 24-word seed phrase used to access the account, generated using BIP39 with 256 bits of entropy
keyInfo.privateKey
Private key for the account. Required for token transfers and often referred to as senderKey
keyInfo.address
Stacks address for the account
keyInfo.btcAddress
Corresponding BTC address for the account.
keyInfo.wif
Private key of the btcAddress in compressed format.
keyInfo.index
Nonce for the account, starting at 0
Note that a new account automatically exists for each new private key. There is no need to manually instantiate an account on the Stacks blockchain.
Alternatively to the CLI creation, the Stacks Transactions JS library can be used:
Finally, you can generate new account using a Stacks-enabled wallet like Leather, Xverse, or Asigna.
Handling different formats
It's common for new Stacks developers to get tripped up on the different ways when specifying Stacks' principal (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 library, which can abstract the conversion for you.

Additional Resources
Last updated
Was this helpful?
