# What is Proof of Work?

Proof of Work is a computationally expensive challenge for computers used to control difficulty and secure a blockchain network through mining, where nodes are financially incentivized to find hashes of data.

Proof-of-Work is a blockchain consensus mechanism and the term "Proof of Work" is used to describe the solution to a computationally expensive challenge for computers.

For instance, we could program a computer to search for a hash starting with three 5's.

That might take some time guessing:

``````sha256("0"); // 5feceb…
sha256("1"); // 6b86b2…
sha256("2"); // d4735e…
// keep on guessing, keep on guessing…
sha256("5118"); // 555850…
``````

Phew, took us a few guesses! 😅

The difficulty to come up with this input gets exponentially harder the more 5s we require the output hash to start with. This is how it's possible to control difficulty of Proof-Of-Work.

### Why would you use Proof of Work?

One of the first use cases of Proof of Work was to prevent spamming on blockchains. The idea is you can make each action a little bit difficult.

If you want to send an email to your grandmother, maybe you need to come up with a hash that starts with three 5s.

If a spammer wants to send an email to a million grandmas, they need to come up with a million hashes with three 5s.

It becomes computationally expensive for them to do this kind of spamming.

Now you might be wondering: Could the spammer just use the same hash for all 1 million emails?

Yes, certainly!

Well, that is, unless we build requirements to make each hash unique.

For instance, we could require that the hash input include the to address and contents in order to send the email.

If I wanted to send my Grandma a message "Hi Grandma!", I'd need to find a hash with my grandma's email address and the contents of the email plus some value to satisfy the hash:

``````sha256("Hi Grandma! [email protected] 0"); // f2d9e2…
sha256("Hi Grandma! [email protected] 1"); // 4ee36e…
sha256("Hi Grandma! [email protected] 2"); // c25e5c…
// keep on guessing, keep on guessing…
sha256("Hi Grandma! [email protected] 424"); // 5552ab…
``````

Found it!

This didn't take my computer very long.

We can manage the difficulty by changing the number of 5s to make it take a minute on my machine.

This way it takes a spammer 1 million minutes (or 11.5 days!) to do it on a machine with similar capabilities.

As a user, I barely notice the difference, yet it's much more troublesome for the spammer!

## 📘

The number that we're appending on the end of the message here is generally referred to as a nonce. We'll see how both Ethereum and Bitcoin make use of nonces in a few ways!

### How does Bitcoin use Proof-of-Work?

You can think of Proof of Work as the security of the Bitcoin system. Thousands of nodes are working to find hashes of data in the Bitcoin network at any given time. These machines are financially incentivized through rewards when they find the hash. This process is known as mining. ⛏

In order to overpower this network and force your own version of the truth, you would need to come up with more computing power than all the nodes in the entire system. This is referred to as a 51% attack because you need to have 51% of the total hashing power in the network.

Even accomplishing this you are extremely limited in what you can actually accomplish.

👆🏼 Understanding this part has quite a bit to do with the underlying data structure of the blockchain itself!

We'll go into this in further detail later.