<p>Which account is entitled to forge the next block depends on several things.</p>

<p>The last block added to the blockchain includes a 32-byte "generation signature" (actually a hash). This signature is concatenated with the public key of each account attempting to forge the next block, then sha256 hashed to produce a new generation signature to be included in the next block, the block currently being forged. The 8 most significant bytes of the new signature are combined into a 64-bit integer in reverse order (little endian) to determine the "hit" value of each account.</p>

<p>These hit values are effectively random and can't be known before the latest block is added to the blockchain, but after that they are known throughout the network. Any account receiving a newly forged block from the network can verify that the generating (forging) account is eligible to forge, because it knows the last block's generation signature and the public key of the forger, both of which are included in the new block, and thus can compute the hit value for any account.</p>

<p>Because the hit value is effectively random, every account with a non-zero EffectiveBalance has a chance to forge. A low hit value is desirable, because then even an account with a low balance can get a hit. The formula for getting a hit is</p>

<p>hit &lt; BaseTarget * EffectiveBalance * TimeSinceLastBlock</p>

<p>The BaseTarget is dynamically adjusted with each new block so that a hit occurs somewhere on the network about once per minute. A hit will eventually occur even if the hit value is by chance very high, because it becomes easier to get a hit with each passing second because of the TimeSinceLastBlock (in seconds) term.</p>

CC BY-SA 3.0
2015-07-22T12:43:30.820Z
But where does "Your probability of forging a block depends on your share of the total number of coins that are active on the network." come into play?
Luca Matteis
CC BY-SA 3.0
2015-07-23T11:08:22.880Z
One main question I have: if Bob wins the current block, is he eligible to forge the next block or does he have to wait 1440 blocks before he can forge again?
Luca Matteis
CC BY-SA 3.0
2015-07-23T15:15:56.177Z
Having a higher balance is like buying more tickets in a lottery. The winning ticket is picked at random, but if you buy several tickets you multiply your chances of winning. Your probability of winning is the numer of tickets you bought divided by the total number of tickets sold to everyone participating in the lottery. The probability of winning the forging contest is your NXT balance divided by the total balance of NXT forging throughout the network. This occurs through the EffectiveBalance term in the hit relationship.
mystcoin
CC BY-SA 3.0
2015-07-23T15:26:57.793Z
right but since the lottery is happening between the users currently forging (active users), wouldn't it be easy for a user with 90% of all the tickets to participate and win almost certainly the round? and would he win also the next round (given he has even more tickets now)?
Luca Matteis
CC BY-SA 3.0
2015-07-23T15:31:09.463Z
Bob is eligible to win the next block, based on his EffectiveBalance which can change from block to block. NXT spent reduces his balance immediately, but received NXT isn't available for forging for 1440 blocks. This delay in crediting deposits is to prevent moving balances from one account to another with a low hit value, hoping to take control of the blockchain. The blockchain cannot be reorganized after 1440 blocks.
mystcoin
CC BY-SA 3.0
2015-07-23T15:37:41.183Z
Yes, if any one account acquired more than 50% of actively forging NXT, he could potentially take over the blockchain. Care was taken to evenly distribute all NXT when it was first created and to monitor the distribution as well as the forging activity since then. The distributioin has improved over time, making the network even more secure.
mystcoin
CC BY-SA 3.0
2015-07-23T15:39:00.537Z
You can observe the forging activity including distribution in real time here: https://nxtportal.org/monitor. Also, observe geographical distribution here: https://nxtportal.org/globe
mystcoin
CC BY-SA 3.0
2015-07-23T16:03:16.637Z
So that means that once a user wins a block, he can't win another block for the next 1440 blocks? But if that's the case, how would a 50% ticket holder win every single block if he has to wait 1440 blocks in between his winnings? This isn't explained very clearly anywhere I've tried in the wiki.
Luca Matteis
CC BY-SA 3.0
2015-07-23T18:50:06.903Z
I wrote above: "Bob is eligible to win the next block..." I was answering your question: "if Bob wins the current block...". To make it absolutely clear: If Bob forges a block, he can theoretically forge the very next block, and the next one after that. To actually do so, he either has to have a very large balance, be very lucky, or both.
mystcoin
CC BY-SA 3.0
2015-07-23T20:20:40.590Z
Ok I'll ask a new question (and accept you for this one)
Luca Matteis
CC BY-SA 3.0
2015-07-23T20:28:13.817Z
In case you're interested: http://bitcoin.stackexchange.com/questions/38753/how-does-nxt-agree-on-a-chain-when-active-accounts-can-be-easily-faked
Luca Matteis
CC BY-SA 3.0
2015-07-22T12:35:06.363Z
2015-07-22T12:35:06.363Z
mystcoin
<p>I've read both the <a href="https://wiki.nxtcrypto.org/wiki/Whitepaper:Nxt" rel="nofollow">Nxt whitepaper</a> and many other resources on the wiki but I still can't seem to understand how exactly the forging process works. From what I understand, there are a bunch of online users with their account "unlocked" (so they can sign the next block if they win). I don't understand how the winner (or the next forger) is decided. Is it random, or is it based on how many nxt coins one has?</p>

<p>For example let's imagine there are three users online with their accounts "unlocked": Alice (has 40 nxt), Bob (has 55 nxt) and Fred (has 13 nxt). The <a href="https://wiki.nxtcrypto.org/wiki/FAQ#Forging" rel="nofollow">wiki</a> says:</p>

<blockquote>
  <p>Your probability of forging a block depends on your share of the total
  number of coins that are active on the network.</p>
</blockquote>

<p>If that's true, wouldn't Bob (who has more coins than Alice and Fred) win the block generation every time? But then how is it possible that even accounts with little coins are still able to win at forging? Does it have something to do with the fact that the winning forger has to wait 1440 blocks before they can forge again? Is this what gives a "chance" to the less-rich users to win sometimes?</p>

<p>Also, if Bob is winning every time, couldn't he just go back the last 10 blocks or so and replace them with different blocks?</p>

<nxt><proof-of-stake><forging>
How is the next forger decided in Nxt?
Luca Matteis
# How is the next forger decided in Nxt?

(Asked by: username_0 on 2015-07-21)

I've read both the [Nxt whitepaper](https://wiki.nxtcrypto.org/wiki/Whitepaper:Nxt) and many other resources on the wiki but I still can't seem to understand how exactly the forging process works. From what I understand, there are a bunch of online users with their account "unlocked" (so they can sign the next block if they win). I don't understand how the winner (or the next forger) is decided. Is it random, or is it based on how many nxt coins one has?

For example let's imagine there are three users online with their accounts "unlocked": Alice (has 40 nxt), Bob (has 55 nxt) and Fred (has 13 nxt). The [wiki](https://wiki.nxtcrypto.org/wiki/FAQ#Forging) says:

> Your probability of forging a block depends on your share of the total
> number of coins that are active on the network.

If that's true, wouldn't Bob (who has more coins than Alice and Fred) win the block generation every time? But then how is it possible that even accounts with little coins are still able to win at forging? Does it have something to do with the fact that the winning forger has to wait 1440 blocks before they can forge again? Is this what gives a "chance" to the less-rich users to win sometimes?

Also, if Bob is winning every time, couldn't he just go back the last 10 blocks or so and replace them with different blocks?

**Tags:** nxt, proof-of-stake, forging


---

## 1 answers

### Answer by username_1 on 2015-07-22. Score: 1 | Accepted answer

Which account is entitled to forge the next block depends on several things.

The last block added to the blockchain includes a 32-byte "generation signature" (actually a hash). This signature is concatenated with the public key of each account attempting to forge the next block, then sha256 hashed to produce a new generation signature to be included in the next block, the block currently being forged. The 8 most significant bytes of the new signature are combined into a 64-bit integer in reverse order (little endian) to determine the "hit" value of each account.

These hit values are effectively random and can't be known before the latest block is added to the blockchain, but after that they are known throughout the network. Any account receiving a newly forged block from the network can verify that the generating (forging) account is eligible to forge, because it knows the last block's generation signature and the public key of the forger, both of which are included in the new block, and thus can compute the hit value for any account.

Because the hit value is effectively random, every account with a non-zero EffectiveBalance has a chance to forge. A low hit value is desirable, because then even an account with a low balance can get a hit. The formula for getting a hit is

hit < BaseTarget \* EffectiveBalance \* TimeSinceLastBlock

The BaseTarget is dynamically adjusted with each new block so that a hit occurs somewhere on the network about once per minute. A hit will eventually occur even if the hit value is by chance very high, because it becomes easier to get a hit with each passing second because of the TimeSinceLastBlock (in seconds) term.

> **Comments:**
> **username_0**: But where does "Your probability of forging a block depends on your share of the total number of coins that are active on the network." come into play?  
> **username_0**: One main question I have: if Bob wins the current block, is he eligible to forge the next block or does he have to wait 1440 blocks before he can forge again?  
> **username_1**: Having a higher balance is like buying more tickets in a lottery. The winning ticket is picked at random, but if you buy several tickets you multiply your chances of winning. Your probability of winning is the numer of tickets you bought divided by the total number of tickets sold to everyone participating in the lottery. The probability of winning the forging contest is your NXT balance divided by the total balance of NXT forging throughout the network. This occurs through the EffectiveBalance term in the hit relationship.  
> **username_0**: right but since the lottery is happening between the users currently forging (active users), wouldn't it be easy for a user with 90% of all the tickets to participate and win almost certainly the round? and would he win also the next round (given he has even more tickets now)?  
> **username_1**: Bob is eligible to win the next block, based on his EffectiveBalance which can change from block to block. NXT spent reduces his balance immediately, but received NXT isn't available for forging for 1440 blocks. This delay in crediting deposits is to prevent moving balances from one account to another with a low hit value, hoping to take control of the blockchain. The blockchain cannot be reorganized after 1440 blocks.  
> **username_1**: Yes, if any one account acquired more than 50% of actively forging NXT, he could potentially take over the blockchain. Care was taken to evenly distribute all NXT when it was first created and to monitor the distribution as well as the forging activity since then. The distributioin has improved over time, making the network even more secure.  
> **username_1**: You can observe the forging activity including distribution in real time here: https://nxtportal.org/monitor. Also, observe geographical distribution here: https://nxtportal.org/globe  
> **username_0**: So that means that once a user wins a block, he can't win another block for the next 1440 blocks? But if that's the case, how would a 50% ticket holder win every single block if he has to wait 1440 blocks in between his winnings? This isn't explained very clearly anywhere I've tried in the wiki.  
> **username_1**: I wrote above: "Bob is eligible to win the next block..." I was answering your question: "if Bob wins the current block...". To make it absolutely clear: If Bob forges a block, he can theoretically forge the very next block, and the next one after that. To actually do so, he either has to have a very large balance, be very lucky, or both.  
> **username_0**: Ok I'll ask a new question (and accept you for this one)  
> **username_0**: In case you're interested: http://bitcoin.stackexchange.com/questions/38753/how-does-nxt-agree-on-a-chain-when-active-accounts-can-be-easily-faked  

---

