Stacking

Introduction

Stacking rewards Stacks (STX) token holders with bitcoin for providing a valuable service to the network by locking up their tokens for a certain time.

Stacking vs Staking

It is crucial to note that this has no impact on block production or validation. Stacks is not a Proof-of-Stake network and _stacking** is different than **staking_.
There are two primary differences between stacking in Stacks and staking in other PoS networks.

Yield generated in burnchain token

In staking, users lock one token and earn their yield in the same token. In stacking, users lock one token (STX) and earn a yield in the "burnchain" token (BTC), rather than the same token that was locked. In PoX, the yield comes from a finite, external source (Bitcoin deposits from Stacks miners). In PoS, the yield comes from the currency's issuance schedule itself, which means it is programmatically unlimited (but theoretically limited, we'll get into this a bit more below).
That's the first main difference. Staking involves a yield of the same token being generated by the issuance mechanism set by the core protocol, where stacking yield requires an input of an external, separate token.
How are these issuance rates set? In Ethereum, issuance rates are determined by network usage. Ethereum's goal is to create a deflationary money supply, so the issuance rate is determined depending on the usage of the network. In order for an Ethereum transaction to be considered valid, it must include a base fee that is burned during transaction execution. The issuance rate is algorithmically determined block-by-block depending on how much ETH is being burned by these base fees plus normal gas fees.
Stacking doesn't have any of this complex functionality, since it does not generate a yield of the same token (and therefore doesn't need to issue new tokens, but rather transfer existing tokens from the base network) and it does not need to maintain an issuance rate. We are speaking here of the yield specifically, Stacks does have an issuance rate and does generate new STX tokens, but this process is completely separate from stacking and the yield generated from it.
The Bitcoin yield that stackers earn is determined by a combination of the Bitcoin being committed by miners and the number of STX tokens that are locked up in the network.

No effect on transaction validation or consensus mechanism

The other main difference is that staking involves validators, and is tightly coupled with the operations of the network.
In both protocols stackers/stakers are earning a yield for providing a service. In PoX, that service is providing economic security by signaling what the canonical Stacks chain is (the chain with the most money locked in it is the real chain) and soon will provide the service of serving as signers for sBTC.
In PoS, the service stakers provide is running a validator node, which is in charge of determining what transactions are or are not valid. So in a PoX system with stacking, the yield generation process is not attached to the validity and operations of the network, whereas in PoS it is.
In PoS, the entities that are locking up their tokens and earning a yield are the same entities that are in charge of determining what does and does not count as a valid transaction. This and the fact that the yield is in the same token that is locked, have large implications on a PoS chain functioning much like equities in that the entities with the largest stake have the most controlling power over the transactional operations of the chain.
Here's an article by Stacks Foundation Developer Advocate Kenny Rogers that goes more in-depth into these economic incentives, with additional resources.
It is important to note that this control does not extend to being able to change the rules of the blockchain itself, but only to vote transactions as valid or invalid.
In order to incentivize honest behavior on the part of validators, stake can be slashed as a punishment. Since PoX stackers do not have any say in transaction validity, this punishment mechanism does not exist and is not necessary in PoX.
Stacking is a built-in action, required by the "proof-of-transfer" (PoX) mechanism. The PoX mechanism is executed by every miner on the Stacks network.
Stacking functionality is implemented as a smart contract, using Clarity. Read more about the contract.

Stacking flow

The Stacking mechanism can be presented as a flow of actions:
  1. 1.
    Make API calls to get details about the upcoming reward cycle
  2. 2.
    For a specific Stacks account, confirm eligibility
  3. 3.
    Confirm the BTC reward address and the lockup duration
  4. 4.
    The transaction is broadcasted and the STX tokens are locked. This needs to happen before the prepare phase of the next reward cycle, the last 100 Bitcoin blocks of the ongoing reward phase
  5. 5.
    The Stacking mechanism executes reward cycles and sends out rewards to the set BTC reward address
  6. 6.
    During the lockup period, details about unlocking timing, rewards and more can be obtained
  7. 7.
    Once the lockup period is passed, the tokens are released and accessible again
  8. 8.
    Display reward history, including details like earnings for previous reward cycles
Keep in mind that the target duration for a reward cycles is ~2 weeks. This duration is based on the target block time of the network (10 minutes) and can be higher at times due to confirmation time variances of the bitcoin network.

Stacking delegation flow

The Stacking flow is different for delegation use cases:
  • Before Stacking can be initiated for a token holder, the delegator needs to be granted permission to Stack on behalf of the account owner. The permission is restricted to the maximum amount the delegator is allowed to Stack. The maximum amount is not limited by the available funds and can be set much higher. An account can only be associated with one single delegator
  • The account has to define the delegation relationship. They can optionally restrict the Bitcoin reward address that must be used for payouts, and the expiration burn block height for the permission, thus limiting the time a delegator has permission to Stack
  • Delegators have to lock Stacks from different accounts ("pooling phase") until they reach the minimum amount of Stacks required to participate in Stacking
  • Once a delegator locks enough STX tokens, they can finalize and commit their participation in the next reward cycle
  • Certain delegation relationships may allow the STX holder to receive the payout directly from the miner (step 5/6)
  • The termination of the delegation relationship can either happen automatically based on set expiration rules or by actively revoking delegation rights

Token holder eligibility

Stacks (STX) token holders don't automatically receive stacking rewards. Instead, they must:
  • Commit to participation before a reward cycle begins
  • Commit the minimum amount of STX tokens to secure a reward slot, or pool with others to reach the minimum
  • Lock up STX tokens for a specified period
  • Provide a supported Bitcoin address to receive rewards (native segwit is not supported)
The following diagram describes how the minimum STX tokens per slot is determined. More information on dynamic minimums for stacking is available at stacking.club.
Token holders have a variety of providers and tools to support their participation in Stacking. The Stacks website contains a list of stacking providers and pools.

Stacking in the PoX consensus algorithm

Stacking is a built-in capability of PoX and occurs through a set of actions on the Stacks blockchain. The full proof-of-transfer implementation details are in SIP-007. Below is a summary of the most relevant actions of the algorithm.
  • Stacking happens over reward cycles with a fixed length. In each reward cycle, a set of Bitcoin addresses associated with stacking participants receive BTC rewards
  • A reward cycle consists of two phases: prepare and reward
  • During the prepare phase, miners decide on an anchor block and a reward set. Mining any descendant forks of the anchor block requires transferring mining funds to the appropriate reward addresses. The reward set is the set of Bitcoin addresses which are eligible to receive funds in the reward cycle
  • Miners register as leader candidates for a future election by sending a key transaction that burns cryptocurrency. The transaction also registers the leader's preferred chain tip (must be a descendant of the anchor block) and commitment of funds to 2 addresses from the reward set
  • Token holders register for the next rewards cycle by broadcasting a signed message that locks up associated STX tokens for a protocol-specified lockup period, specifies a Bitcoin address to receive the funds, and votes on a Stacks chain tip
  • Multiple leaders can commit to the same chain tip. The leader that wins the election and the peers who also burn for that leader collectively share the reward, proportional to how much each one burned
  • Token holders' locked up tokens automatically unlock as soon as the lockup period finishes

Bitcoin address

You must provide a BTC address in one of two formats:
The Stacking contract needs a special format for the Bitcoin address (the reward address). This is required to ensure that miners are able to correctly construct the Bitcoin transaction containing the reward address.
The address must be specified in the following format using the Clarity language:
;; a tuple of a version and hashbytes buffer
(pox-addr (tuple (version (buff 1)) (hashbytes (buff 20))))
The version buffer must represent what kind of bitcoin address is being submitted. It can be one of the following:
SerializeP2PKH = 0x00, // hash160(public-key), same as bitcoin's p2pkh
SerializeP2SH = 0x01, // hash160(multisig-redeem-script), same as bitcoin's multisig p2sh
SerializeP2WPKH = 0x02, // hash160(segwit-program-00(p2pkh)), same as bitcoin's p2sh-p2wpkh
SerializeP2WSH = 0x03, // hash160(segwit-program-00(public-keys)), same as bitcoin's p2sh-p2wsh
The hashbytes are the 20 hash bytes of the bitcoin address. You can obtain that from a bitcoin library, for instance using bitcoinjs-lib:
const btc = require("bitcoinjs-lib");
console.log(
"0x" +
btc.address
.fromBase58Check("1C56LYirKa3PFXFsvhSESgDy2acEHVAEt6")
.hash.toString("hex")
);

Choosing the right Stacking strategy

Here is an interesting article that may help you choose the right Stacking strategy.

Where to Stack?

You can Stack on your own, on a pool or on an exchange:

Stacking on your own

Stacking on your own is non-custodial.
Stacking on your own requires a protocol minimum (amount changes but about 100,000 STX).
Hiro Wallet allows stacking on your own.

Stacking on a pool

Stacking on a pool allows Stacking without the requirement of the protocol minimum.
Some available pools are:
Pool
Type
Pays rewards in
Fee
Minimum amount
Non custodial
STX or xBTC
No
40 STX
Non custodial
BTC
5%
200 STX
Stacked
Non custodial
BTC
100,000 STX
Xverse
Non custodial
BTC
No
100 STX

Stacking on an exchange

Stacking on an exchange is custodial, meaning you are trusting the exchange with your Stacks.
Several exchanges allow Stacking directly on their sites. Examples are Okcoin and Binance

Stacking statistics

You can view all sorts of Stacking data and statistics on Stacking Club