It specifies what the first few characters must look like for the hash to be accepted. You can check out and play around with the UI to see how it works.īlockchains do not use just any hash generated because of security reasons. Every string passed to the SHA256 library will always return the same 64-character long string every time. The SHA256 library takes any data given to it and returns a 64-character long string. SHA256 is the most popular and is used by many renowned companies. But we will use the SHA256 library for this tutorial. There are a lot of libraries for generating a block's hash. We are using the OOP method because blockchain programming uses the same pattern.īut before we start building, let's learn how to generate the hash for every block in a blockchain. Let's use some JavaScript object-oriented programming to demonstrate how blockchain works. The process of calculating the hash is known as proof of work. The hash of a block gets generated when mining. The process secures and verifies the transactions contained in a block. The whole process of adding a new block is known as mining. The block may now be added to the others. If the user has completed a set of transactions they need at a time, they can use those transactions to create a block. Next, any user on the network can perform at least one transaction. Now that sounds really stressful and almost impossible. This implies that for a hacker to gain access and break the network, they need to generate the hashes and match them to the right block without breaking other blocks. Among other things, a block contains a hash, the previous block hash, and at least one transaction.Įvery block in the blockchain keeps a record of its hash and the previous block’s hash to keep the network safe from hackers. So it begins with one block called the genesis block. Theory Behind the BlockchainĪ blockchain is a connection of many blocks. We will begin by looking at how it works in theory and then how we can replicate it using a programming language that many devs already know – JavaScript. In this section, I will explain what happens in a blockchain application behind the scenes. Web 2 emerged sometime around the early 2000s and is the phase in which users can read and write data. Web 1 was the stage where users could only read data. It differs from centralized applications where the company owns the data, and the consumers just hope their data isn’t misused.Įxamples of decentralized applications include Bitcoin and Ethereum, while centralized applications include Facebook and Google.īlockchain technology falls under the category of Web 3 simply because it is the third phase of the internet in which users can read, write, and own data. Not following these terms will incur consequences such as losing all of a person’s savings or leaving the association after paying a fine.īlockchain is known as a decentralized technology since data and authority are shared equally among everybody in the network. Whenever they decide to add a new member, the person becomes part of the signatories and gets a copy of the account history.Įveryone must consent before a withdrawal happens outside the proposed date. So they open an account.Įach time one of them deposits money, everyone gets a new account history document emailed to them. The three agree that no one will be the boss, and each person will have equal access to the account to ensure trust. Everyone must agree upon any updates before they are accepted.Īnyone who tries to mutilate their document without the others' consent is seen as fraudulent and will suffer predefined consequences.įor example, imagine that a group of friends (Njoku, Samson, and Ebere) decides to start a peer-to-peer savings account that must run for a certain period before a withdrawal is possible. You can see blockchain as a document that holds the details of transactions made by a group of people where everyone has a copy. Everyone here has equal access to the data circulating within the network. The Blockchain is a network of transactions or assets called blocks where every block is connected to the others. One of these that will be particularly helpful is the concept of object-oriented programming (OOP). This tutorial assumes that you understand some foundational coding concepts. In in addition to my explanation and code examples, I've included lots of videos you can use to supplement your learning. This will give you a strong foundation in blockchain development, and set you up for success in coding your own smart contracts. This tutorial you're reading is what I wish I could send back in time to myself. The first time I tried to learn blockchain development, I felt overwhelmed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |