Ready to start your Web3 development journey?
→ Download our guide to developing smart contracts

Securing Web3 Apps Through Bitcoin: An Overview of Stacks’ Consensus Mechanism

Creating a secure consensus mechanism for blockchains is difficult. We know this from experience. Popular consensus mechanisms like Proof of Work and Proof of Stake have well-studied tradeoffs. Proof of Transfer is a novel consensus mechanism that combines desirable attributes of both PoW and PoS and introduces some unique capabilities along the way.

Type
Deep dive
Topic(s)
Stacks
Published
March 8, 2022
Author(s)
CTO
Securing Web3 Apps Through Bitcoin: An Overview of Stacks’ Consensus Mechanism
Contents
Copy link

The reason different approaches to consensus exist is because they all grapple with the blockchain trilemma: creating solutions that are simultaneously decentralized, secure, and scalable is a very hard engineering problem. We in the Stacks community believe that the best approach to solving this problem lies with using Bitcoin as a secure foundation. Ultimately that’s why Stacks core developers created the Proof of Transfer (PoX) consensus mechanism: to provide dApps with the security of the largest and most secure blockchain—Bitcoin—so they no longer have to bootstrap their own.

Stacks’ PoX consensus mechanism recycles Bitcoin’s existing Proof-of-Work computations to secure Stacks and periodically settles Stacks transactions on the Bitcoin blockchain. To change the history of Stacks, you’d also have to change the history of Bitcoin. That means that Stacks inherits Bitcoin’s security.

What Is a Consensus Mechanism?

A consensus mechanism is how nodes in a network reach agreement with each other on what transactions have been validated. Blockchains are networks without a centralized authority, and with no authority to say “this is the truth about the state of things,” network nodes need another way to reach consensus.

Without a consensus mechanism, there can be no universally agreed upon ledger of transactions. New transactions can’t successfully be registered, invalid transactions might be recorded on-chain, and users’ assets on the blockchain won’t be secure.

Blockchains broadly achieve consensus by requiring their nodes to dedicate some resources to validate and secure new transactions. Here are the two most common consensus mechanisms:

Proof-of-Work Consensus Mechanism

In PoW, a subset of nodes called “miners” dedicate computational resources to secure new blocks. Generally, those computational resources are put towards solving mathematical problems for a chance to validate transactions and earn a block reward. Bitcoin is the most popular example of a PoW chain. 

  • Process: The miner who solves the math problem first gets to add the next block to the blockchain, securing the current state of the ledger, and earning the block rewards.
  • Incentives: Miners are incentivized to act in the best interests of the blockchain because they would waste electricity and computational resources if they tried to act maliciously to execute attacks (such as double spend attacks, empty block attacks, or blockchain reorganization), and they would forgo the block rewards.
  • Criticisms: One of the common criticisms is PoW’s environmental impact due to the amount of energy it requires to solve the computational problems. If Bitcoin were a country, it would be one of the top 30 countries consuming the most electricity.

Proof-of-Stake Consensus Mechanism

In PoS, miners dedicate financial resources to secure the blockchain. In this model, miners stake tokens to the network in exchange for a chance to validate transactions and earn a reward. Polkadot and Cardano are two popular PoS blockchains, and Ethereum is in the process of migrating from PoW to PoS. 

  • Process: Validators propose blocks to be added, and the blockchain randomly selects a cohort of validators to secure the new block.
  • Incentives: Validators are rewarded with block rewards when they validate blocks. Nodes can report other nodes acting maliciously (such as being unavailable, signing multiple blocks simultaneously, or trying to introduce bias into the randomness of the validation selection). Malicious nodes get a slashing penalty that reduces their stake or revokes their validator status.
  • Criticisms: One of the common criticisms with PoS is that validators with large stakes could gain excessive influence on the network. This is because in a PoS model, “the rich get richer,” and larger stakes lead to larger rewards. Other criticisms include the Nothing-at-Stake problem, where there is no opportunity cost for validators to stake on competing versions of the blockchain to maximize their rewards, as well as the lack of forks. Forks effectively act as a self-correcting mechanism allowing the network to recover from all sorts of potential issues. Without them, if a PoS network is ever overtaken by colluding miners, the rest of the network doesn’t have any recourse.

Beyond PoW and PoS, there are other consensus mechanisms used on other blockchains. The main difference in how blockchains achieve consensus is dependent on the tradeoffs they are willing to make across the trilemma of decentralization, security, and scalability

Recycling PoW to Secure New Blockchains: From Proof-of-Burn to Proof-of-Transfer

Blockchains don’t scale easily because they have limited blockspace. And as they become widely adopted, demand for blockspace outstrips supply. One option for increasing the scalability of blockchains is to simply create more blockchains. More blockchains, more blockspace to go around. 

The question in that scenario then becomes: can we secure new blockchains by leveraging the computational and financial resources already spent in other blockchains? This would address scalability without creating new environmental problems and without creating security issues as you try to bootstrap decentralization from scratch.

In the context of PoW, here are two solutions to recycle the “work” of a different blockchain to secure a new one, reducing the environmental impact of PoW.

Proof-of-Burn Consensus Mechanism

PoB is a consensus mechanism layered on PoW to enable miners to participate in the consensus protocol without having to set up mining rigs. Instead, the miners “burn” the tokens of a PoW chain by sending them to an address that verifiably cannot spend the tokens, taking them out of circulation forever.

  • Process: Miners participate in the consensus process by burning the tokens of one blockchain to have the chance to mine new blocks in a different one. Miners can increase their chances of being selected by increasing the number of tokens burned.
  • Incentives: The miners are rewarded in the tokens of the new blockchain when they are chosen to mine a new block. Because the miners burn tokens for a chance to mine a block, they have “skin in the game” and are incentivized to act in the best interests of the network. Their burned tokens are wasted if the blockchain becomes insecure in the wake of malicious activity.
  • Criticisms: One of the major criticisms of PoB is that it is wasteful in the same way that PoW is wasteful: the tokens burned in PoB are gone forever. Additionally, the process of burning coins is opaque and can be hard to verify, and we have yet to see a successful PoB blockchain achieve meaningful scale.

Proof of Transfer Consensus Mechanism

PoX is a new consensus mechanism designed and developed by Stacks as a way to secure a new blockchain by recycling the PoW computation of an existing blockchain. Similar to PoB, miners send tokens (BTC in the case of Stacks) to a series of addresses determined by the consensus mechanism. However, unlike PoB those addresses belong to users, as a reward for users locking up their tokens for network stability. Rather than tokens being burned and taken out of circulation, they are transferred to users in the network.

  • Process: Miners transfer BTC for the chance to validate a block. The blockchain selects a winner using a weighted random function in which the chance of winning the block is proportional to the amount of BTC transferred relative to other miners.
  • Incentives: For validating a block, miners receive newly-minted STX tokens and the transaction fees for that block. Similar to PoB, miners are incentivized to avoid malicious behavior because undermining the blockchain would lead to the loss of the transferred BTC.
  • Criticisms: One criticism of PoX is that it is possible for miners to “discount mine,” in which they mine new blocks while simultaneously stacking tokens as a network participant. Through that process, miners could earn rewards as both a miner and network participant. This could theoretically encourage miner consolidation, but we have yet to see that occur in practice.

Learn more about Stacks connection to Bitcoin in the first episode of Web3 on Bitcoin Explained:

What Does Proof of Transfer Mean for Developers?

PoX is a novel consensus mechanism that enables some unique benefits. By connecting two different blockchains through PoX, developers can leverage the strengths of different blockchains while avoiding their weaknesses, and in the process build user experiences that can’t exist in other types of consensus and bootstrap their growth more quickly. 

You Can Build Secure Web3 Apps

PoX eliminates the difficult choice between programmability and security when developers want to pick an underlying blockchain for their Web3 apps. Bitcoin is the most secure and decentralized blockchain, but its design does not allow for smart contracts. This makes it difficult to build decentralized applications on Bitcoin, and many developers who would have loved to build their application on Bitcoin often chose less secure chains out of necessity. With PoX, developers can now build applications on a programmable blockchain (Stacks) that then settle on the more decentralized blockchain (Bitcoin) and benefit from Bitcoin’s security. 

You Can Accelerate User Adoption 

Through PoX, developers can accelerate user adoption because users can earn rewards in a more established cryptocurrency. You can de-risk the user’s decision to participate in consensus because Bitcoin is less risky than a brand new token that has not yet proven its worth and may make participation more appealing to the general public. Developers can also leverage PoX to build novel incentivization structures. For instance, Arkadiko uses PoX to create self-repaying loans, and CityCoins uses PoX to create city-specific currencies to help communities support local governments.

You Promote Democratized Access

PoX enhances democratized access to blockchains and blockchain-powered applications because anyone can be a miner without needing to invest in expensive mining equipment or having in-depth DevOps experience. All that is required to participate in the consensus process on a PoX chain is to send some tokens to an address. Secondly PoX, democratizes access by being user-verifiable: anyone can easily verify the state of the blockchain. Democratization and open-access are core to the ethos of Web3. PoX embraces that, and developers can use these same properties to build apps with open access.

How Does Stacks’ Proof of Transfer Consensus Mechanism Work?

Stacks delivers fully expressive smart contracts secured by Bitcoin without modifying Bitcoin’s core. Simply put, PoX enables Bitcoin applications. Here’s how it works.

image.png
Source

PoX is designed to be open access, so that anyone can participate. To participate in PoX, miners transfer BTC to predefined addresses that correspond to the address of Stackers (more on them in a moment) for a chance to mine the next Stacks block. The consensus rules select the winning miner using a verifiable random function (VRF) to ensure true randomness. The successful miner, in turn, writes the next block of the Stacks blockchain and receives the block rewards and the transaction fees from that block paid out in newly minted STX tokens, the gas token for the Stacks network. 

Stacks users can also participate in the consensus mechanism through a process called “Stacking.” Users can lock up their Stacks (STX) tokens during a Stacking cycle, which lasts two weeks. By stacking STX, users signal support that the Stacks network is reliably functional and sufficiently stable to encourage miners to participate in PoX. Stackers, in turn, are eligible to receive a prorated share of the BTC committed by the miners during the Stacking cycle.

The rewards incentivize economically rational users to stack their tokens. Stacking the tokens takes them out of circulation to add more value to the network, and more token holders rely on the increasing value to expand their participation in the network.

Ready to Build on Stacks?

We spent years in research and development to design the Proof of Transfer mechanism. It is what enables Stacks’ connection to Bitcoin and what we believe will accelerate its adoption. Now that you have an idea of how PoX leverages Bitcoin to secure the Stacks blockchain, are you ready to build applications for Bitcoin?

Download our free guide to developing smart contracts to kickstart your journey into Web3.

Download the Guide
Copy link
Hiro news & product updates straight to your inbox
Only relevant communications. We promise we won’t spam.

Related stories