DEV Community

loading...
Cover image for Blockchain development using Ethereum,  Web3.js, Solidity Smart Contracts [Part 1]

Blockchain development using Ethereum, Web3.js, Solidity Smart Contracts [Part 1]

Gaurav Adhikari
I am passionate about modern web apps. I am available for freelance work and projects.
・6 min read

Blockchain:

N|Solid

“What the internet did for communications, blockchain will do for trusted transactions.” - Ginni Rometty, CEO of IBM

After hearing the word Blockchain, possible questions which come up in your mind maybe

  • Is Blockchain a technology, culture or process change?
  • How is BlockChain able to achieve things quite faster?
  • How is Cryptocurrency linked to BlockChain?
  • What is the role of BitCoin in BlockChain?

This article is going to make much of the things clear and simpler, so let's get started. 😉

Course Coverage

  • What is Blockchain and its significance?
  • Blockchain Types
  • Cryptographic Techniques
  • Types of Cryptocurrency
  • Details about Bitcoin
  • Blockchain Applications and trending information

Let's first understand the concept of intermediaries and their roles in-detail before we dive into BlockChain.

Example 1 - Electronic Money Transfer
In case of an electronic Money Transfer (by an individual or business), Banks track and record the transaction.

While sending money from one account to another account, Bank approves, tracks and records the transaction for each party in their private accounts before the amount actually reflects in the receiver's account.

Example 2 - Real Estate
Governments record the change of land rights/property ownership when a person buys a property or land into some legal documents.
If the records are not maintained, there would be complete disorder and confusion, and anyone could potentially claim ownership of anything.

Issues with the traditional system:

  • Centralized power
  • Private ledgers(or records)
  • Prone to hacking/corruption

Let's imagine direct business-to-business or peer-to-peer transactions without the involvement of any Government, Banks or any intermediary.
Welcome to the World of Blockchain! 😀

What is Blockchain?

Imagine Blockchain as a Google spreadsheet, where everyone makes changes/updates and shares with other users.
Also, it has a unique feature, where every update is final, and nobody can tamper with it.

Wikipedia defines Blockchain as “A blockchain, originally block chain, is a growing list of records, called blocks, that are linked using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data.”

Here is an infographic from Zignuts.com explaining the working of Blockchain:

N|Solid

Blockchain addresses the intermediary issues by providing the following features:

  • Decentralized Power - Blockchain uses the P2P node networking system.
  • Public Ledgers - Each node in the network has its own public ledger with details of all transactions.
  • Immutable hacking - Since the same data is available in the distributed network, modification is impossible.
  • Cryptography - To maintain the blocks in Blockchain, Blockchain uses a complex mathematical algorithm.

Types of Blockchain

  • Public Blockchain
  • Private Blockchain

- Consortium/Federated Blockchain

Blockchain is split on the basis of the access to the blockchain data (or transaction). You can quickly understand the three blockchain types from the comparison picture given below.

N|Solid
Saved your time haan! 😎

Cryptography:

Cryptography is a technique that converts plain text into an encrypted text, thus making it difficult for some random person to manipulate the data.
N|Solid

In Symmetric cryptography, the same key is used for encrypting and decrypting data. This is fast but the problem comes in sharing the key. If it is compromised more damage is caused. So in blockchain, we use Asymmetric cryptography. ??.
A pair of keys is used in Asymmetric Cryptography (Public key & Private key).
N|Solid
Party A will encrypt the transaction using Public key of Party B, then Party B can simply decrypt the transaction using its Private key. Hence the need to share private key is not required.

Hashing

N|Solid

Hashing is an algorithm that encrypts data of any arbitrary length to a fixed length.

This output is a smaller representation of the original data and it is called Digest or HASH.

These HASHes can be used to validate the data that came from as each HASH is uniquely connected to the original message.

Few Online hash generators. You can run an MD5, SHA1, SHA-256 and other hashing functions on your data here:

onlinemd5.com
sha1-online.com

What is Cryptocurrency?
Now we understand blockchain technology uses cryptography to protect the network.

  • Cryptocurrency is a combination of Cryptography and Currency.
  • Cryptocurrency is the digital currency that uses encryption techniques to regulate the generation of money and verify the transfer of funds without depending upon any type of central authority.

Types of Cryptocurrencies
Some of the trending cryptocurrencies are Bitcoin, Litecoin, Ripple, Ethereum, Zcash, etc.
N|Solid

Bitcoin

Here, you will understand more about the famous Cryptocurrency Bitcoin.
Bitcoin was invented by a pseudonymous group of individuals under the name Satoshi Nakamoto as open-source software in 2009.
Read it here bitcoin.org/bitcoin.pdf

  • It is the first decentralized cryptocurrency
  • It used cryptography for controlling its creation and management
  • It is created and held electronically in a peer to peer open ledger (public blockchain)

How to procure Bitcoins?

  • Buying them on an exchange like Coinbase, Coinmama, Luno, etc.
  • As the exchange of products and services.
  • Through mining

Mining in Bitcoin

N|Solid

In simple words, mining is verification of bitcoin transactions.
Example:

  • Aastha wants to buy some products from Gaurav using bitcoin.
  • To make sure her bitcoin is genuine, miners start verifying the transaction.
  • The transaction gets approved only after Miners look into the transaction history of Aastha to verify if Aastha has enough valid bitcoins.
  • Once the transaction is approved, it is updated in the public ledger as a new block, and the message is propagated to all the users in that blockchain network.

The Miner who validates the transaction first gets to put a subsequent block into the blockchain. To incentivize mining, the miners are rewarded with newly released bitcoins.

Famous Blockchain Frameworks

Most popular Blockchain frameworks include the following:

  • Ethereum
  • Hyperledger
  • R3 Corda

A quick comparison between three is given below

Ethereum Hyperledger R3 Corda
Permissionless and generic Blockchain platform Modular and permissioned platform Specialized distributed and permissioned ledger platform
Governed by Ethereum developers Governed by Linux foundation Governed by R3
Mining based on Proof of Work (POW) Multiple consensus approaches - at transaction level Specific consensus at the transaction level
Consensus approached at Ledger level - -

We'll be coding in Solidity programming language in Ethereum framework to develop our dapps (decentralized apps). Excited? Mee too! 🤪

Blockchain use cases:

  1. Banking and payments - Giving access to financial services to everyone around the world including those countries that don’t have access to traditional banking. ABRA: Bitcoin Based Remittance service Barclays
  2. Cybersecurity - Data is verified and secured using Cryptographic Hashes
  3. Supply Chain Management - Transactions are kept in a permanent decentralized record and monitored securely and transparently. Product authenticity or fair trade can be easily verified using a distributed ledger. Provenance, Fluent, Skuchain, and Blockverify
  4. Forecasting - Research, consulting, analysis and forecasting AUGUR
  5. Networking and IoT Autonomous Decentralized Peer-to-Peer Telemetry (ADEPT) by Samsung and IBM is a new concept that will create a decentralized network of IoT devices.
  6. Insurance - This technology is useful for any type of insurance that relies on real-world data AETERNITY
  7. Private Transport & Ride Sharing - Blockchain technology can be used to build a decentralized version of peer-to-peer ridesharing apps allowing both users and car owners to arrange terms and conditions in a secure way without third-party providers. ARCADE CITY LA`ZOOZ
  8. Online Data Storage - Centrailzed servers are vulnerable to hacking, data loss, and human error. Using Blockchain technology allows cloud storage to be more secure, robust and attack proof. STORJ: DECENTRALIZED CLOUD STORAGE
  9. Charity - Common complaints in the charity space include inefficiency and corruption which prevent money from reaching those who are meant to have it. Blockchain can help track donations to make sure your money is going in right hands. BITGIVE
  10. Voting - Blockchain can be used for voter registeration, verification, and electronic vote counting to ensure that only legitimate votes are counted and no votes are changed or removed. Immutable, public-viewable ledgers of recorded votes would make elections more fair and democratic. DEMOCRACY EARTH FOLLOW MY VOTE
  11. Governments - Government systems are often slow, opaque, and prone to corruption. Implementing Blockchain-based system can significantly reduce bureaucracy and increase security, efficiency, and transparency of governmental operations. DUBAI IS GETTING TO PUT ALL ITS GOVERNMENT DOCUMENTS ON THE BLOCKCHAIN BY 2020
  12. Healthcare - Hospitals need a secure platform to store and share sensitive data. Blockchain can allow hospitals to safely store medical records and share them with authorized professionals or patients. It will improve data accuracy and can also fast the process of diagnosis. GEM TIERION
  13. Energy Management - Energy producers and users cannot buy it directly from each other and have to go through the public grids or trusted private intermediary. TRANSACTIVEGRID
  14. Online Music - Blockchain startups are arising with a way for musicians to get paid directly from their fans without giving up large percentages of sales to platforms or record companies. MYCELIA UJO
  15. Retail - Sorry Amazon OPENBAZAAR OB1
  16. Real Estate - Some of the problems in buying and selling property are bureaucracy, lack of transparency, fraud, and mistakes in public records. Blockchain solves this issue too. UBIQUITY

Thanks! Let me know if you are interested for next part in comment.. :P

Discussion (1)

Collapse
oggo profile image
oggo

Nice topic, i'm definitely interested :-)

Forem Open with the Forem app