• Crypto Lists
  • Bitcoin
  • Blockchain
  • ICO
  • Cryptocurrency
  • Altcoin
  • Advertise With Us
Newsletter
ItsBlockchain
  • Blockchain
  • Bitcoin
    featured

    A starter guide to Bitcoin Options trading

    Featured Image

    With Bitcoin Mining Capitulation Coming to an End, Will Halving Pump Begin?

    featured image

    Technical Indicators suggests Bitcoin can crash to 7000$ in next few days

    featured image

    Why is Bitcoin a safe haven in a financial crisis

    featured image

    How to Make Money in Crypto When It Falls

    featured image

    Despite Resurrection of Old Bitcoiners, HODL Waves Indicate Bullish Accumulation

    featured image

    Top 5 Online Merchants That Accept Cryptocurrency

    featured image

    An account into Bitcoin Lightning Network Progress and other Scalability Solutions

    featured image

    Why Bitcoin [BTC] Could Fall to $5,000. Now that Halving is Done

    Trending Tags

    • Altcoin
    • Crypto Lists
    • Trade Signal
    • News
      Bitcoin Market’s Sentiments turned bullish after USA President’s recent press conference

      Bitcoin Market’s Sentiments turned bullish after USA President’s recent press conference

      featured image

      Breaking : Crypto Trading is now legal in South Korea

      RBI to allow crypto trading

      Supreme court of India decided to lift off RBI Banking BAN against Bitcoin

      featured image

      Steemit Joining TRON Ecosystem

      Reliance Jiocoin

      Reliance Jio is preparing for Jio Coin launch in 2020

      A $134 Million real estate has sold on ethereum blockchain

      A $134 Million real estate has sold on ethereum blockchain

      Hacking attacks on cryptocurrency exchanges

      Hacking Attacks on Cryptocurrency Exchanges are rising, Why?

      Bithumb Launches in India

      Bithumb Global Launches in India

      US-China trade war effect on Bitcoin Price

      US-China trade war effect on Bitcoin Price

    • Crypto Market
    • Guide
    No Result
    View All Result
    • Blockchain
    • Bitcoin
      featured

      A starter guide to Bitcoin Options trading

      Featured Image

      With Bitcoin Mining Capitulation Coming to an End, Will Halving Pump Begin?

      featured image

      Technical Indicators suggests Bitcoin can crash to 7000$ in next few days

      featured image

      Why is Bitcoin a safe haven in a financial crisis

      featured image

      How to Make Money in Crypto When It Falls

      featured image

      Despite Resurrection of Old Bitcoiners, HODL Waves Indicate Bullish Accumulation

      featured image

      Top 5 Online Merchants That Accept Cryptocurrency

      featured image

      An account into Bitcoin Lightning Network Progress and other Scalability Solutions

      featured image

      Why Bitcoin [BTC] Could Fall to $5,000. Now that Halving is Done

      Trending Tags

      • Altcoin
      • Crypto Lists
      • Trade Signal
      • News
        Bitcoin Market’s Sentiments turned bullish after USA President’s recent press conference

        Bitcoin Market’s Sentiments turned bullish after USA President’s recent press conference

        featured image

        Breaking : Crypto Trading is now legal in South Korea

        RBI to allow crypto trading

        Supreme court of India decided to lift off RBI Banking BAN against Bitcoin

        featured image

        Steemit Joining TRON Ecosystem

        Reliance Jiocoin

        Reliance Jio is preparing for Jio Coin launch in 2020

        A $134 Million real estate has sold on ethereum blockchain

        A $134 Million real estate has sold on ethereum blockchain

        Hacking attacks on cryptocurrency exchanges

        Hacking Attacks on Cryptocurrency Exchanges are rising, Why?

        Bithumb Launches in India

        Bithumb Global Launches in India

        US-China trade war effect on Bitcoin Price

        US-China trade war effect on Bitcoin Price

      • Crypto Market
      • Guide
      No Result
      View All Result
      ItsBlockchain
      No Result
      View All Result
      Home Uncategorized

      The Blockchain Explained to Web Developers, Part 1: The Theory

      Hitesh Malviya by Hitesh Malviya
      February 24, 2020
      in Uncategorized
      0 0
      1
      blockchain
      0
      SHARES
      77
      VIEWS
      Share on FacebookShare on Twitter

      The blockchain is the new hot technology. If you haven’t heard about it, you probably know Bitcoin. Well, the blockchain is the underlying technology that powers Bitcoin. Experts say the blockchain will cause a revolution similar to what Internet provoked. But what is it really, and how can it be used to build apps today? This post is the first in a series of three, explaining the blockchain phenomenon to web developers. We’ll discuss the theory, show actual code, and share our learnings, based on a real world project.

      To begin, let’s try to understand what blockchains really are.

      What Is A Blockchain, Take One

      Although the blockchain was created to support Bitcoin, the blockchain concept can be defined regardless of the Bitcoin ecosystem. The literature usually defines a blockchain as follows:

      A blockchain is a ledger of facts, replicated across several computers assembled in a peer-to-peer network. Facts can be anything from monetary transactions to content signature. Members of the network are anonymous individuals called nodes. All communication inside the network takes advantage of cryptography to securely identify the sender and the receiver. When a node wants to add a fact to the ledger, a consensus forms in the network to determine where this fact should appear in the ledger; this consensus is called a block.

      The Thinker, by Rodin

      I don’t know about you, but after reading these definitions, I still had troubles figuring out what this is all about. Let’s get a bit deeper.

      Ordering Facts

      Decentralized peer-to-peer networks aren’t new. Napster and BitTorrent are P2P networks. Instead of exchanging movies, members of the blockchain network exchange facts. Then what’s the real deal about blockchains?

      P2P networks, like other distributed systems, have to solve a very difficult computer science problem: the resolution of conflicts, or reconciliation. Relational databases offer referential integrity, but there is no such thing in distributed system. If two incompatible facts arrive at the same time, the system must have rules to determine which fact is considered valid.

      Take for instance the double spend problem: Alice has 10$, and she sends twice 10$ to Bob and Charlie. Who will have the 10$ eventually? To answer this question, the best way is to order the facts. If two incompatible facts arrive in the network, the first one to be recorded wins.

      double spend

      In a P2P network, two facts sent roughly at the same time may arrive in different orders in distant nodes. Then how can the entire network agree on the first fact? To guarantee integrity over a P2P network, you need a way to make everyone agree on the ordering of facts. You need a consensus system.

      Consensus algorithms for distributed systems are a very active research field. You may have heard of Paxos or Raft algorithms. The blockchain implements another algorithm, the proof-of-work consensus, using blocks.

      Blocks

      Blocks are a smart trick to order facts in a network of non-trusted peers. The idea is simple: facts are grouped in blocks, and there is only a single chain of blocks, replicated in the entire network. Each block references the previous one. So if fact F is in block 21, and fact E is in block 22, then fact E is considered by the entire network to be posterior to fact F. Before being added to a block, facts are pending, i.e. unconfirmed.

      How blocks group facts

      Mining

      Some nodes in the chain create a new local block with pending facts. They compete to see if their local block is going to become the next block in the chain for the entire network, by rolling dice. If a node makes a double six, then it earns the ability to publish their local block, and all facts in this block become confirmed. This block is sent to all other nodes in the network. All nodes check that the block is correct, add it to their copy of the chain, and try to build a new block with new pending facts.

      Rolling dice

      But nodes don’t just roll a couple dice. Blockchain challenges imply rolling a huge number of dice. Finding the random key to validate a block is very unlikely, by design. This prevents fraud, and makes the network safe (unless a malicious user owns more than half of the nodes in the network). As a consequence, new blocks gets published to the chain at a fixed time interval. In Bitcoin, blocks are published every 10 minutes on average.

      In Bitcoin, the challenge involves a double SHA-256 hash of a string made of the pending facts, the identifier of the previous block, and a random string. A node wins if their hash contains at least n leading zeroes.

      // a losing hash for Bitcoin
      787308540121f4afd2ff5179898934291105772495275df35f00cc5e44db42dd
      // a winning hash for Bitcoin if n=10
      00000000009f766c17c736169f79cb0c65dd6e07244e9468bc60cde9538b551e
      

      Number n is adjusted every once in a while to keep block duration fixed despite variations in the number of nodes. This number is called the difficulty. Other blockchain implementations use special hashing techniques that discourage the usage of GPUs (e.g. by requiring large memory transfers).

      The process of looking for blocks is called mining. This is because, just like gold mining, block mining brings an economical reward – some form of money. That’s the reason why people who run nodes in a blockchain are also called miners.

      Note: By default, a node doesn’t mine – it just receives blocks mined by other nodes. It’s a voluntary process to turn a node into a miner node.

      Money and Cryptocurrencies

      Every second, each miner node in a blockchain tests thousands of random strings to try and form a new block. So running a miner in the blockchain pumps a huge amount of computer resources (storage and CPU). That’s why you must pay to store facts in a blockchain. Reading facts, on the other hand, is free: you just need to run your own node, and you’ll recuperate the entire history of facts issued by all the other nodes. So to summarize:

      • Reading data is free
      • Adding facts costs a small fee
      • Mining a block brings in the money of all the fees of the facts included in the block

      We’re not talking about real money here. In fact, each blockchain has its own (crypto-)currency. It’s called Bitcoin (BTC) in the Bitcoin network, Ether (ETH) on the Ethereum network, etc. To make a payment in the Bitcoin network, you must pay a small fee in Bitcoins – just like you would pay a fee to a bank. But then, where do the first coins come from?

      A pile of Bitcoins

      Miners receive a gratification for keeping the network working and safe. Each time they successfully mine a block, they receive a fixed amount of cryptocurrency. In Bitcoin this gratification is 25 BTC per block, in Ethereum it’s 5 ETH per block. That way, the blockchain generates its own money.

      Lastly, cryptocurrencies rapidly became convertible to real money. Their facial value is only determined by offer and demand, so it’s subject to speculation. At the time of writing, mining Bitcoins still costs slightly less in energy and hardware than you can earn by selling the coins you discovered in the process. That’s why people add new miners every day, hoping to turn electricity into money. But fluctuations in the BTC value make it less and less profitable.

      BTC to USD

      Contracts

      So far we’ve mostly mentioned facts storage, but a blockchain can also execute programs. Some blockchains allow each fact to contain a mini program. Such programs are replicated together with the facts, and every node executes them when receiving the facts. In bitcoin, this can be used to make a transaction conditional: Bob will receive 100 BTC from Alice if and only if today is February 29th.

      Other blockchains allow for more sophisticated contracts. In Ethereum for instance, each contract carries a mini-database, and exposes methods to modify the data. As contracts are replicated across all nodes, so are their database. Each time a user calls a method on the contract and therefore updates the underlying data, this command is replicated and replayed by the entire network. This allows for a distributed consensus on the execution of a promise.

      This idea of pre-programed conditions, interfaced with the real world, and broadcasted to everyone, is called a smart contract. A contract is a promise that signing parties agree to make legally-enforceable. A smart contract is the same, except with the word “technically-“ instead of “legally-“. This removes the need for a judge, or any authority acknowledged by both parties.

      Public hearings of the Court presided over by H.E. Judge Rosalyn Higgins (February/March 2006)

      Imagine that you want to rent your house for a week and $1,000, with a 50% upfront payment. You and the loaner sign a contract, probably written by a lawyer. You also need a bank to receive the payment. At the beginning of the week, you ask for a $5,000 deposit; the loaner writes a check for it. At the end of the week, the loaner refuses to pay the remaining 50%. You also realize that they broke a window, and that the deposit check refers to an empty account. You’ll need a lawyer to help you enforce the rental contract in a court.

      Smart contracts in a blockchain allow you to get rid of the bank, the lawyer, and the court. Just write a program that defines how much money should be transferred in response to certain conditions:

      • two weeks before beginning of rental: transfer $500 from loaner to owner
      • cancellation by the owner: transfer $500 from owner to loaner
      • end of the rental period: transfer $500 from loaner to owner
      • proof of physical degradation after the rental period: transfer $5,000 from loaner to owner

      Upload this smart contract to the blockchain, and you’re all set. At the time defined in the contract, the money transfers will occur. And if the owner can bring a predefined proof of physical degradation, they get the $5,000 automatically (without any need for a deposit).

      You might wonder how to build a proof of physical degradation. That’s where the Internet of Things (IoT) kicks in. In order to interact with the real world, blockchains need sensors and actuators. The Blockchain revolution won’t happen unless the IoT revolution comes first.

      Such applications relying on smart contracts are called Decentralized Apps, or DApps.

      Smart contracts naturally extend to smart property, and a lot more smart things. The thing to remember is that “smart” means “no intermediaries”, or “technically-enforced”. Blockchains are a new way to disintermediate businesses – just like the Internet disintermediated music distribution.

      Disintermediation

      Tag: web development in blockchain, how does the blockchain work, blockchain data structure, how does blockchain work, blockchain news, how blockchain works, blockchain database, blockchain technology, blockchain applications, blockchain explained, blockchain, what is a blockchain, blockchain com, blockchain app, what is the blockchain, sidechain. what is sidechain, sidechain blockchain, blockstream sidechain, what is blockstream

       

      IBC-Transparent-Logo-(1)

      Subscribe To Our Newsletter

      Join our mailing list to receive Cryptocurrency investing and trading recommendations to your mailbox.

      You have Successfully Subscribed!

      Tags: blockchainBlockchain Developerdevelopment
      ShareTweetPin

      Subscribe to get notified on latest posts.

      Unsubscribe

      Related Posts

      Top 5 IEOs

      TOP 5 IEOs by ROI in USD

      by Hitesh Malviya
      September 11, 2019
      0

      The first I heard about IEO when Binance launchpad announced the token sale of BitTorrent in starting of the year....

      bitcoin cash price prediction

      Bitcoin cash Price prediction: to hit 350$ by next week

      by Hitesh Malviya
      May 7, 2019
      0

      Bitcoin Cash is getting all attention to what it needs lately. Bitcoin cash benefitted the most from BCHSV Delisting Chaos....

      Cryptocurrencies infographics

      33 Cryptocurrencies Described In Four Words Or Less {Infographics}

      by Hitesh Malviya
      April 17, 2019
      0

      Cryptocurrency is the new exciting technology at present which is poised to disrupt the way the financial transactions take place....

      Wyoming leads blockchain charge in U.S., Colorado Follows Suit

      Wyoming leads blockchain charge in U.S., Colorado Follows Suit

      by Hitesh Malviya
      March 14, 2019
      0

      Blockchain technology, especially in the form of cryptocurrencies and digital assets, is already extremely popular and widely used across the...

      Litecoin To Hit 3-Digit Value By August 2019?

      Litecoin To Hit 3-Digit Value By August 2019?

      by Hitesh Malviya
      March 8, 2019
      0

      Do you think it is an impossible scenario seeing Litecoin, the fifth most popular cryptocurrency, going from its current price...

      Load More

      About Us

      We share important articles on blockchain technology here. Our mission is to spread the awareness about blockchain technology to masses through content.

      • Trending
      • Comments
      • Latest
      featured image

      List of leading partners of Ripple, and How they use XRP?

      May 2, 2020
      featured image

      List of ChainLink Partnerships which skyrocketed the growth of LINK cryptocurrency

      May 12, 2020
      featured

      A starter guide to Bitcoin Options trading

      July 6, 2020
      How to Buy Cryptocurrency in China

      How to Buy Cryptocurrency in China

      February 17, 2020
      featured image

      Top 10 Low market cap altcoins to invest in 2020

      June 2, 2020
      binance exchange safe

      How Safe is Binance Exchange

      August 21, 2020
      featured image

      Is Civic(CVC) a Good Investment – Detailed Insight

      June 24, 2020
      playcent

      Introducing Playcent- Decentralised Wix for interactive apps and games

      December 14, 2020
      RioDeFi Builds a Bridge to India before its long awaited IDO on Uniswap

      RioDeFi Builds a Bridge to India before its long awaited IDO on Uniswap

      September 27, 2020
      Bitcoin [BTC] Price Analysis – Monthly Returns

      Bitcoin [BTC] Price Analysis – Monthly Returns

      September 1, 2020
      Featured Image

      PrimeXBT – A Smart Platform to Trade Crypto, Forex, and CFD

      August 28, 2020
      featured image

      Bitcoin [BTC] Price Prediction: Parabolic Fractals from 2019

      August 2, 2020
      featured image

      Top 10 Staking Coins Everyone Should Know About

      July 26, 2020
      featured

      4 Interesting Ways Blockchain Technology Impacts Higher Education

      July 21, 2020
      • featured image

        List of leading partners of Ripple, and How they use XRP?

        137 shares
        Share 137 Tweet 0
      • List of ChainLink Partnerships which skyrocketed the growth of LINK cryptocurrency

        55 shares
        Share 55 Tweet 0
      • Top 5 DeFi Crypto Projects

        52 shares
        Share 52 Tweet 0
      • Top 10 Low market cap altcoins to invest in 2020

        20 shares
        Share 20 Tweet 0
      • Bitcoin lost 4.5 years old support, drop below 3000$ possible

        124 shares
        Share 124 Tweet 0
      ItsBlockchain

      We are India’s first and oldest Blockchain & Cryptocurrency publication platform started in 2016. We are a one-stop destination for technical analysis, cryptocurrency recommendations, and Blockchain technology resources.

      Buying Guides

      • Buy Bitcoins in India
      • Buy Bitcoins in China
      • Buy bitcoins in Russia
      • Buy Bitcoins in Japan
      • Buy Bitcoins in Turkey

      Important Links

      • Home
      • About US
      • Privacy Policy
      • Promote Your ICO
      • Submit post

      Follow Us

      Contact us

      support@itsblockchain.com

      © 2020 itsblockchain.com - Designed and maintained by Fanatic Coders

      No Result
      View All Result
      • About US
      • Home
      • Newsletter
      • Privacy Policy
      • Promote Your ICO
      • Submit post

      © 2020 itsblockchain.com - Designed and maintained by Fanatic Coders

      Login to your account below

      Forgotten Password?

      Fill the forms bellow to register

      All fields are required. Log In

      Retrieve your password

      Please enter your username or email address to reset your password.

      Log In
      This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.