DEV Community

Cover image for Making Sense Of Blockchain And CryptoCurrency
Elegberun Olugbenga
Elegberun Olugbenga

Posted on • Updated on • Originally published at Medium

Making Sense Of Blockchain And CryptoCurrency

This article is my attempt to make sense of blockchain and cyptocurrency. I will be demystifying blockchain technology and explaining various cryptocurrency lingua franca.

WHAT IS BLOCKCHAIN?

A blockchain is an auditable database. A database in which data can only be added but not removed or changed. Data can be periodically added to the database in things called blocks. As the name implies, a series of these blocks chained together is called a Blockchain.

WHAT IS CRYPTOCURRENCY?

This is a digital currency in which transactions are verified and records maintained by a decentralized system using cryptography. Combining blockchain and cryptocurrency together. A blockchain is a network of computers (nodes) that run software to confirm the security and validity of (digital currency)on the network. Blockchain is the network and cryptocurrency is what is being spent on the network. Bitcoin is currently the most popular Blockchain and cryptocurrency but other blockchains exist like Etherum with (ether)as the currency being spent on the network.

DECENTRALIZED VS CENTRALIZED

Most legacy financial institutions use a centralized system wherein user data is stored and managed by a private entity or group of entities. All users connect to a single source of data in that sense. This sort of relationship is called a centralized network, a major downside to this is that it provides a single point of failure. If the centralized database is wiped out all the data is lost and because a single entity(central bank)has power over the system they can make changes as they please. On the other hand in a decentralized network, data is stored on different nodes(computers)in the network and none of the nodes is managed by a central authority, all of the nodes have to somewhat agree to trust each other, the participating nodes have the exact copy of the database. If one node is down other nodes can provide the data. This provides a redundant and resilient network that ensures high reliability.

How does the blockchain work?

Centralized Vs Decentralized

Centralized Vs Decentralized

HOW DOES THE BLOCKCHAIN WORK?

Imagine a large hall with briefcases on one end and glass on the other end, each briefcase has a lock and a chain that connects it to the next briefcase. Everyone can see the briefcases through the glass. But only the person who has the key to a briefcase can open it. Supposing I want to transfer money(currency) from my briefcase to yours I will need my key(crypto) to open and sign the transaction. Everyone looking through the glass will see that the transaction belongs to me along with the details of the transaction; as soon as it gets to you, you broadcast to everyone that you have received your money so everyone takes a note of it. After a period of time, someone gathers all these mini transactions and collates them into blocks which are then added to the chain; at a simplistic level, this is how a blockchain works. It is a series of these blocks chained together; It consists essentially of two parts: A Block and a chain. I refer to a block as a collection of transactions and a chain as the linking mechanism which checks if the block's signatures are valid.

We define a bitcoin as a chain of digital signatures. Each owner transfers bitcoin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin. A payee can verify the signatures to verify the chain of ownership.
-Satoshi Nakamoto, Bitcoin Whitepaper
The blockchain is downloaded by all the nodes in the network; when a new block is added to the chain, verification is done to check if the block is valid. If valid, it makes a copy of that block and forwards it to the other nodes in the network till all nodes have that block added to their chain.

How does the blockchain work?

How does the blockchain work

How does the blockchain work

WHAT IS CRYPTO MINING?

This process of verifying if a block is valid is done by nodes called miners. Cryptocurrency mining is a term that refers to the process of gathering cryptocurrency as a reward for work that you complete. (This is known as Bitcoin mining when talking about mining Bitcoins specifically.) Whenever transactions are made, all network nodes receive them and verify their validity. Miner nodes go to collect all these transactions from the memory pool and attempts to organize them into blocks. The nodes perform a series of hashing functions (hard mathematical problems)according to preset protocols by that crypto network until it finds a valid hash. When a valid hash is found, the node that finds the hash will broadcast the block to the network. All other nodes will check if the hash is valid and, if so, add the block into their copy of the blockchain. This process of hashing the transactions to form blocks requires a lot of computational power therefore the nodes that perform these hashes are rewarded for their efforts. Nodes can combine together to pool resources so the currency reward is shared amongst them.
Mining Farm

Mining Farm

CONSENSUS ALGORITHM

Proof Of Work

One of the challenges with distributed systems is ensuring honesty. How do we ensure that each node in the network is honest and the miners of these blocks do not just bring an invalid block without doing the proper work?. The answer can be found in a consensus algorithm. These are a series of algorithm mechanisms that govern miners in a blockchain, all the nodes know this algorithm so they can check for its validity. It is sorta like a lie detector in the chain. It verifies that the hashed block the miner is proposing is valid. If a miner brings forth an invalid hashed block. It would have wasted its computational time, resources, and reputation. If it brings a valid block it gets rewarded in the native coin. This type of consensus algorithm is called proof of work because miners have to prove that they have done the work.

Proof Of Stake

In proof of stake instead of sacrificing computation resources nodes sacrifice crypto coins in a process known as staking. A pseudo-random node is selected based on some conditions to forge a new block. The node then stakes a percentage of its coin as a down payment that it's going to forge the block correctly. When the node completes the block It gets rewarded with transaction fees for its work. If it tries to cheat by not forging the block correctly. It loses both its stake and its reputation.
HALVING is a process where by the reward miners get for mining is reduced. This is done to reduce the total value of its crypto coins in circulation.

A PRACTICAL EXAMPLE

Gbenga and Ada are on the ecoin network. Gbenga wants to send 3 ecoins to Ada. Let's walk through the process.
Address- Both Gbenga and Ada need an address. The first time Gbenga issues a transaction. A private and a public key is generated, the private key for Gbenga to sign the transaction, and a public key for other people to verify Gbengas signature. Ada will also need all these at her end. After solving the address problem Gbenga then issues a statement saying "I Gbenga belonging to this address(123) is sending 3 ecoins to Ada in this address (1234)". He issues this statement with a hash of his public key and his signature (private key).When the coin gets to Ada she can verify it is his signature because of his public key. Ada then signals to the rest of the network that she has gotten her coins. As other people on the network hear that message, each adds it to a queue of pending transactions that they've been told about, but which haven't yet been approved by the network. David "a miner" checks his copy of the blockchain, and can see that each transaction is valid. He would like to help out by broadcasting news of that validity to the entire network so it can be added as a block. However, before doing that, as part of the validation protocol David is required to solve a hard computational puzzle - the proof-of-work. Without the solution to that puzzle, the rest of the network won't accept his validation of the transaction.
Once David solves this problem he is rewarded with a crypto coin and the block of transactions is added to the network.
Head to this site bitcoin explorer. -> Latest Blocks -> View All ->Select a Block that has been mined. You can see all the transactions associated with that block. You can hover on each column to get the information on the transaction.

WHAT IF I WANT TO EXCHANGE CRYPTOCURRENCIES?

I understand how the exchange is done within a blockchain. But what if I want to exchange an ecoin for a gcoin?. There are two main ways to do this Centralized Exchanges vs Decentralized.

Centralized Exchanges

In this type of exchange, a centralized body helps you swap coins. It manages your blockchain's private keys and handles the responsibility involved in managing transactions. (It's funny having a centralized body manage a decentralized system🤔). Supposing I want to swap x amounts of coin A for y amounts of coin B. The exchange removes x amounts of coins A value from my coin A crypto wallet and records it on its ledger. It then creates a crypto B wallet (if I have none )to store coin B and purchase coin B on my behalf. After which it gives my coin A to other people willing to buy coin A. The more people that want to buy coin A the more coin As the value goes up. Popular examples of centralized exchanges are Binance and CoinBase.

Decentralized Exchanges

In a way, these work similarly to the centralized exchanges except that you have the responsibility of storing your own private keys. Your keys are not managed by a "central entity". This essentially allows peer-to-peer (P2P) trading, enabling you to directly transfer funds to the interested buyer/seller, without having to go through middlemen.
Decentralized exchanges work on agreements(smart contracts). The seller raises an order to sell and after filling in the necessary transaction details an advert is placed on a marketplace. Once a buyer agrees on terms with the seller a smart contract is created which cannot be changed until the payment is confirmed and both parties are settled.

SMART CONTRACTS

A contract is an agreement between two parties what makes this one "smart" is that the third party(Lawyer, Bank) is replaced by a computer program that both parties understand. Why are smart contracts needed?. They can be used for a variety of reasons one of which is that they allow more systems to utilize an existing blockchains network. Supposing I want to create an app that can use blockchain technology to help me transfer music across a network in a secure way. I can go two ways
Create my own blockchain network(Very stressful)
Utilize an existing blockchains network(Less stressful)

The blockchain owners give me a smart contract guideline to follow in my app. With this smart contract, I can create my own token and peg it to the blockchain's native currency I then give my users my own token to use on the platform. An example will be:
Let's imagine I have a token called etoken. I want to use an existing blockchains network in our case let's say the Binance smart chain for my new project. To use it I need the blockchains native coins(BNBs). I decided that 5000 etoken is going to be worth 1BNB.I need 10,000 of these BNB tokens which will cost me 100,000 dollars. But there is a problem I cannot afford the BNB tokens. To raise money I go through a process known as an INITIAL COIN OFFERING.
Basically, I tell people to give me their money for my huge project coming up, I then reward the people with my etoken which they can use on my app. People will need to trust my project to give me their cash. After I get the cash I buy the BNB tokens which I can then use on the blockchains network.
Imagine Samuel a user on my app wants to buy music from Alice another user. An agreement is formed on the blockchain using a smart contract. This smart contract contains an agreement between Alice and Samuel. In the simplest terms, the agreement will look like this: "WHEN Samuel pays Alice 20 etokens, THEN Samuel will receive the music ". The blockchain checks if the smart contract is valid and then fulfills the transaction.

AUTOMATED MARKET MAKERS

Automated market makers are like robots that give you the price of a currency using a formula. In traditional order books, let's say I have Ether and I want to trade it for Bitcoin. I will need to put out an advert that I am selling ETH for BTC. If I get a buyer we will then have to go through the hassle of negotiating till we come to a common agreement and the swap happens. But AMMs cut out this hassle process. It uses a formula to calculate the price of each asset automatically, allowing for a very fast and seamless swap between assets. People often refer to it as P2C(Peer to Computer) as against P2P(Peer to Peer). The exact technicalities of how it does this are beyond the scope of this reading but in summary.
-People submit their cryptocurrencies into a pool called a Liquidity pool. Anytime there is going to be a transaction with that cryptocurrency. The robots interact with that pool to get the currency to exchange.
-The people that submit their cryptocurrencies into the pool are rewarded a percentage of each transaction that happens with that currency.
-What price you get for an asset you want to buy or sell is determined by a formula. This formula can vary with each protocol.

COINS VS TOKENS

With respect to my example on smart contracts, coins are native to their own blockchain. Whilst tokens have been built on top of another blockchain.

FORKING

In the cryptocurrency world, a fork is when there is a change in the rules of the blockchain that the coin operates on or the nodes disagree on a historic transaction(s). Supposing you can your group of friends have been taking left on every turn and then you get to a particular turn and someone takes right. If no one joins him then he is left alone and excluded from the network. But if a minority of people go along he has created a new rule which can be said he has forked out of the original group. In cryptocurrency, if a lot of nodes agree with each other they can decide to fork out of the original network and create their own rules. A popular example is Bitcoin Cash which was forked out of the original Bitcoin.

NON FUNGIBLE TOKENS

NFTS are unique digital assets. They are different from other cryptocurrencies because of one major reason. There are non-fungible. A fungible asset is one that is indistinguishable from one another. 1000 naira in your hand is the same value as it is in mine. With NFTS that is not the case. Its value is unique based on the NFT. I could digitize my painting into an NFT and then issue it out. People that purchase my NFTS now have a digital version of my painting. NFTS can be traded like other cryptocurrencies. But how do I assign value to my NFTS? As with all things in life, a value of a thing is determined by how much people deem it valuable.

STORE OF VALUE

Some cryptocurrencies like Bitcoin are often referred to as digital gold due to their anti-inflationary nature. A pound of gold today is worth more than it was in 1970 which cannot be said about any other currency. Bitcoin bears similarities to gold in this regard. The value of 1BTC in 2021 is 1000 percent more than it was in 2011. Some may argue that the price of Bitcoin tends to crash from time to time. As with gold, the value is determined by how much people are willing to purchase it at that time.

Blockchain technology has the potential to impact several domains- from voting to healthcare, social media, finance it comes with a lot of promises, some of which include transaction automation as in the case of smart contracts which can function without the need of middlemen. Solving the trust problem, the lack of trust is the reason why a lot of organizations spend a lot on security and data protection. Blockchain helps to increase trust within parties that do not currently trust one another. Transparency due to the open and immutable state of the blockchain. They are publicly viewable and can be audited. Blockchain technology allows users to share data, openly and securely having confidence that the data is protected and both parties can be trusted to deliver.

Conclusion

In this article, I have explained some concepts in the blockchain and cryptocurrency sphere and I do hope I have provided some useful information as you continue in your Blockchain journey.

REFERENCES AND FURTHER READING

-How CryptoCurrency Works
-What is Block Chain
-What is Bitcoin ?
-how-the-bitcoin-protocol-actually-works
-what-is-ethereum
-What Is a Smart Contract and How Does it Work?
-How-do-smart-contracts-work
-what-is-cryptocurrency-mining
-ERC-20 Token Standards
-a-guide-to-crypto-collectibles-and-non-fungible-tokens-nfts
what-is-cryptocurrency#centralized-exchanges-cex

-How does a decentralized exchange work and what are the most promising decentralized exchanges?
-Binance Exchange
-So what problems does block chain actually solve?
-what-is-crypto-mining-how-does-cryptocurrency-mining-works
-What is an Automated Market Maker

Follow me here and across my social media for more content like this Twitter Linkedin

Top comments (2)

Collapse
 
cryptokit profile image
CryptoKit

Wow, great guide. There isn't that much on crypto dev here even though the tech is free to use but this article does a good job laying it out for people that want to begin their journey. Hearts all around.

Collapse
 
gbengelebs profile image
Elegberun Olugbenga

Thank you CyptoKit,glad you enjoyed it