If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

How Blockchain Works: Under the Hood

Learn the technology behind blockchain. We dive into the inner workings of blockchain and explain the concepts that make this technology possible. From distributed ledgers to proof of work, get a clear understanding of how blockchain technology operates. Created by Code.org.

Want to join the conversation?

Video transcript

I'm David Schwartz. I'm the CTO at Ripple. My name is Juan Benet. I am the founder and CEO of Protocol Labs. Ripple's, a financial services company, heavily focused on improving international payment flows and bringing blockchain technology to enterprises and financial services companies. Protocol Labs is an R&D organization that builds protocols, tools and services to improve the Internet. The best way to explain blockchain technology is by looking at the first example Bitcoin. Bitcoin is a form of digital money. It was released in 2009 and is still the most popular cryptocurrency. Bitcoin doesn't need a central authority to validate transactions over the network like a bank. Instead, it's a peer to peer decentralized network. Users on the network verify transactions by completing complex math problems, essentially ordering the transactions from the past 10 minutes or so, and they receive Bitcoin in return, ensuring the transactions are correct and keep the network secure. To build trust, everything user addresses, transactions and more on the network is publicly traceable. Unlike the algorithms or databases in a traditional bank. But how can a currency work without a government or a bank? Let's think through an example together. Say you and five other people are all trying to buy and sell stuff from each other and you want to do it without traditional money and without anyone in charge. You'd need a way to track all transactions. You could have a book that you all share, and each time you buy or sell something, you write that down. This is called a ledger. It tracks all the purchases and transactions in a group, but it doesn't make sense to have just one ledger. You have just one ledger. You're back to a centralized system. If one person destroys the ledger or makes a fake ledger, the system breaks down. Instead, each of you has your own copy of the ledger to keep track of the transactions. This is like being your own bank because everyone has a copy of the ledger. Any time a transaction happens, it needs to be sent to the entire network so everyone can update their own copy. But wait, what's to stop someone from sending a fake transaction? Showing someone paying the money? The solution is to use something called a digital signature. Anyone sending a transaction must include a cryptographic signature that nobody else can create, only them. This proves the transaction came from them. You can also include a timestamp, and this way you know which transactions are authentic and in what order they happen. But what if different people have disagreements about the ledger without anybody in charge? How would we know whose copy is correct? The answer involves a mechanism called consensus, which requires enough people to agree on which transactions are valid. How does this work? The group verifies the transactions in batches called blocks when everybody agrees on a block. They add it to their own copy of the ledger. Each block includes a digital summary or hash of all the transactions in that block, plus all previous transactions. This digital summary connects the blocks together in a chain, which is why this way of storing information is called a blockchain. Now, how do these folks agree on a block? What prevents an attacker from publishing fake blocks? How do we tell the good ones from the bad ones? To add a block to the chain, we need to find a special value called a proof of work that requires a lot of computing power to find. Think of it like searching for and finding a missing puzzle piece that completes the block in a way everyone can verify. It takes a lot of computing power to produce each proof of work. So it would take an astronomical amount of work for one person to try and find the proof of work for many blocks, let alone all of them. As an attacker, if you wanted to try to add a fake block to the chain, you could get lucky and get that special piece of information for one block. But if you did, you couldn't do it reliably for the next block and the next block. Eventually, you’d get caught. Because of this, over time, only authentic transactions remain in the blockchain. The system we described with six people could also work for 6000 or 6 million. But does everyone need to do all of these very expensive proofs of work? Well, if enough people are doing this computing work, the rest of us can participate more easily because we trust the network as a whole. But wait, why are all these people even doing all this work? This is the really cool part. Blockchain technology typically has a built in reward. When you find the special piece of information, to complete a block of transactions. You get to include one more transaction to give some money to yourself as payment for the work you did to help protect the blockchain. That's why the people doing this work are called miners. It's very much like mining for gold. You do work and you get paid. When there are only a few miners it is easier to collect this money and that creates an incentive for more and more miners to join in. Enough to make the system secure for the rest of us. So that's it. The system we described enables a decentralized currency. To summarize one, the currency works on a shared ledger of transactions. Two, to keep a shared ledger, the information is stored in blocks. Three, the blocks are verified using proof of work. Four, each time a block is verified It's added to the blockchain. Five, the miner who verified it gets a reward. And six, those rewards keep enough miners involved to make the system safe. This method of storing information on a blockchain creates a system of trust without a central authority. This is useful beyond just making a cryptocurrency like Bitcoin. It has potential applications in many other domains, as we'll learn in the next video.