# Proof of Stake Voting¶

## Overview¶

Proof-of-Stake (PoS) voting is a form of Proof-of-Stake (PoS) security, but the way Decred integrates this as a complement to Proof-of-Work (PoW) mining gives it a distinctive set of roles and characteristics.

PoS voting serves a number of purposes:

1. Allowing stakeholders to vote for or against proposed changes to the Decred blockchain. If stakeholders vote in support of a change, the chain will hardfork and the new feature becomes active automatically. More information on voting can be found in the Mainnet Voting Guide.
2. Providing a mechanism for stakeholders to influence Proof-of-Work (PoW) miners. Stakeholders can vote to withhold a miner’s reward even if the block conforms to the consensus rules of the network. This allows stakeholders, in principle, to discourage problematic mining behavior such as mining empty blocks.
3. For a block to be valid, it has to be signed by at least 3 of the 5 tickets that are called to vote in that block. This makes the Decred blockchain more robust to certain kinds of attack, such as those which rely on secret mining.
4. The same principle makes the Decred blockchain resistant to contentious hard forks. PoW Miners are unable to build on a chain without the Votes of the tickets that are called.
5. Snap voting of live tickets is used to make decisions about the project treasury through Politeia.

These roles are incentivized; ticket-holders (or “Proof-of-Stake (PoS) Voters”) collectively receive 30% of the block reward when their tickets are called to vote.

## How Ticket Voting Works¶

To participate in PoS voting, stakeholders lock some DCR in return for a ticket. Every ticket owned gives its holder the ability to cast a single vote. Upon voting, each ticket returns a small reward plus the original Ticket Price of the ticket. Each ticket is selected to vote at random, giving an average vote time of 28 days, but possibly requiring up to 142 days, with a 0.5% chance of expiring before being chosen to vote (this expiration returns the original Ticket Price without a reward). Every block mined must include 5 votes (Miners are penalized by a reward deduction if fewer than 5 votes are included).

Every block mined can also include up to 20 fresh ticket purchases. A new ticket requires 256 blocks to mature before it is entered into the Ticket Pool and can be called to vote.

There are a few important variables that you should familiarize yourself with while staking.

Every 144 blocks (~12 hours), the stake difficulty algorithm calculates a new Ticket Price in an attempt to keep the Ticket Pool size near the target pool size of 40,960 tickets. This 144 block window is referred to as the StakeDiffWindowSize.

The Ticket Price/Stake Difficulty is the price you must pay for a ticket during a single 144 block window.

The Ticket Pool is the total number of tickets in the Decred network.

The Ticket Fee (ticketfee) is the fee rate that must be included in the ticket purchase to incentivize Proof-of-Work (PoW) miners to include that ticket in a new block. Ticket Fee usually refers to the DCR/kB fee rate for a ticket purchase transaction. Therefore, with a higher transaction size, you will end up paying a higher absolute fee. For example, solo-staking ticket purchases are around 300 Bytes, which means a Ticket Fee of 0.3 DCR/kB will result in the spending of 0.1 DCR, if and only if, that ticket gets included in a block.

When a ticket is called to vote, the wallet that has voting rights for that ticket must be online. If the wallet is not online to cast its vote, the ticket will be marked as missed and you will not receive a reward for that ticket. In practice, Solo Voters often run voting wallets on a number of servers on different continents, to minimise the chance of their tickets missing a call to vote.

Voting Service Providers (VSPs) (formerly “Stakepools”) offer a service whereby ticket buyers can delegate the act of voting to the VSP. The ticket-buyer instructs the VSP how their ticket should vote on any open rule change proposals, but transfers voting rights to the VSP to take advantage of the voting infrastructure they provide (i.e. at least three always-online servers).

VSPs charge a fee for this service, which is taken out of the reward returned upon a successful vote. This fee is generally 5% or less. A list of VSPs is maintained on decred.org. VSPs do not take custody of DCR. By using them, you only delegate the voting rights of a ticket.

## Ticket Lifecycle¶

Purchasing a ticket is quite simple (see below), but what happens to it after you buy it? A ticket on mainnet (testnet uses different parameters) will go through a few stages in its lifetime:

1. You buy a ticket using a Decrediton or dcrwallet wallet. The total cost of the each single ticket transaction should be Ticket Price + Ticket Fee(ticketfee).
2. Your ticket enters the mempool. This is where your ticket waits to be mined by PoW miners. Only 20 fresh tickets are mined into each block.
3. Tickets are mined into a block, with higher Ticket Fee transactions having a higher priority. Note that the Ticket Fee is DCR per KB of the transaction. A few common transaction sizes are 298 Bytes (a solo ticket purchase) and 539 Bytes (a pool ticket purchase).
4. A - If your ticket is mined into a block, it becomes an immature ticket. This state lasts for 256 blocks (about 20 hours). During this time the ticket cannot vote. At this point, the ticket fee is non-refundable.
B - If your ticket is not mined, both the Ticket Price and Ticket Fee are returned to the purchasing account.
5. After your ticket matures (256 blocks), it enters the Ticket Pool and is eligible for voting.
6. The chance of a PoS voting is based on a Poisson distribution with a mean of 28 days. After 28 days a ticket has a 50% chance to have already voted.
7. Given a target pool size of 40960 tickets, any given ticket has a 99.5% chance of voting within ~142 days (about 4.7 months). If, after this time, a ticket has not voted, it expires. You receive a refund on the original Ticket Price.
8. A ticket may miss its call to vote if the voting wallet does not respond or two valid blocks are found within close proximity of each other. If this happens, you receive a refund on the original Ticket Price.
9. After a ticket has voted, missed, or expired, the funds (ticket price and reward if applicable, minus the fee) will enter immature status for another 256 blocks, after which they are released. If a ticket is missed or expired, a ticket revocation transaction is submitted by the wallet which then frees up the locked ticket outputs. NOTE: Revocations can only be submitted for a corresponding missed ticket. You cannot revoke a ticket until it is missed.