Bitcoin basics: What is the difficulty target and how does it adjust itself?

hello again everybody and welcome to

another episode of the whatever this is

called so in this video I'm going to be

talking about difficulty target

difficulty retargeting and how that's

calculated in Bitcoin and this concept

can be also applied to pretty much any

cryptocurrency that uses proof-of-work

as its consensus algorithm so people

often would talk about the difficulty

target and the difficulty retargeting

algorithm in Bitcoin and you know I

always wondered what exactly that meant

I knew it had something to do with

mining but I decided to to do a bit of

research and make this video so just as

a bit of background the way Bitcoin

works is that a new block is added to

the Bitcoin blockchain about every 10

minutes and by block I mean another set

of transactions and that block is added

to the blockchain which is the ledger of

all the transactions that occurred in

Bitcoin but where does this 10-minute

number come from it's not like there's

some guy sitting in a room with a

stopwatch and adding another block to

the blockchain every 10 minutes it's not

how it works at all so basically what's

actually happening is there are Bitcoin

mining rigs that are solving this

cryptographic puzzle and when they solve

it they get to be the ones to add

another block to the blockchain and they

get to claim the reward for finding that

and this cryptographic puzzle on average

takes about ten minutes but this ten

minute number it's totally an inexact

science and in fact for a long time it's

been closer to about nine and a half

minutes rather than ten minute

and it also varies based off of how much

computing power is being dedicated to

solving this cryptographic puzzle so if

there's a lot of computers working

towards mining bitcoins then it'll take

less than ten minutes if there are fewer

than normal computers attempting to mine

Bitcoin then it'll take more than ten

minutes one of these miners could just

get extraordinarily lucky and solve the

puzzle within a minute or 30 seconds or

two seconds there's nothing stopping

that from happening other than

probability like I said the ten minute

block time is an average block time a

lot of times you'll have a block that

gets discovered after five minutes you

might have one that gets discovered

after 15 minutes it's not perfectly

exact and that's why it's an average

block time over a large enough number of

blocks that averages out to being ten

minutes so the question becomes how is

this ten minutes in between blocks aka

the block time how is that maintained

how does it stay as ten minutes because

all the time more and more processing

power is being dedicated to Bitcoin

mining so you would think that it would

just constantly shrink the block time

until blocks were being discovered you

know every few seconds well the answer

to that question is the difficulty

retargeting that the Bitcoin protocol

goes through so in every single Bitcoin

block there's a value known as the

difficulty this value determines how

difficult the cryptographic puzzle

that's being solved is and the more

difficult it is the more processing

power it'll take to solve within a

reasonable amount of time

aka ten minutes this value can be

represented as a decimal value like this

or a hexadecimal value like this I have

another video where it goes into a lot

more detail about how exactly this

cryptographic puzzle works so you can

watch that link is in the description

so what the Bitcoin protocol does is

every 2016 blocks or roughly two weeks

the Bitcoin protocol looks at the time

stamps for all of those 2016 previous

blocks and determines whether or not it

took longer than two weeks or shorter

than two weeks if it took longer than

two weeks for those 2016 blocks to get

mined the protocol will lower the

difficulty thus making the puzzle easier

to solve and making it so it happens

quicker if it took less than two weeks

to mine those 2016 blocks it will make

the difficulty target higher and thus

making the cryptographic puzzle more

difficult and so it'll take longer for

the miners to mine the Bitcoin these

calculations take place across all the

nodes on the Bitcoin network and every

node would come to the same conclusion

because they all have the same previous

2016 blocks and if they don't Bitcoin is

forked so here's roughly the formula

that the Bitcoin protocol uses to

determine what the new difficulty should

be so basically it's taking the old

difficulty and multiplying it by twenty

thousand one hundred and sixty minutes

which is two weeks divided by the amount

of time the last 2016 blocks

took to mine so we can pretty clearly

see that if it took less than two weeks

for the last 2016 blocks to get mined

this will result a number larger than

one and by extension raise the

difficulty value and make it more

difficult for the miners to solve the

cryptographic puzzle and thus

maintaining the ten-minute block time

and what we can see is that without this

difficulty retargeting in this this

adjustment then the block time would

just get shorter and shorter as

more and more miners joined the network

and more and more computing power was

put towards mining Bitcoin the puzzle

would just get solved quicker and

quicker now there is a limit to how much

the difficulty can go up and down when

this difficulty retargeting occurs it

can't go up by more than a factor of

four and it can't go down by more than

25% so I think that's it for this video

thank you very much for watching I

always appreciate your viewership I

always appreciate your comments have a

wonderful rest of the whatever and keep

on doing good