• Crypto Lists
  • Bitcoin
  • Blockchain
  • Cryptocurrency
  • Altcoin
  • Advertise With Us
  • Join our Telegram Community
Newsletter
ItsBlockchain
  • Blockchain
  • Bitcoin
    crypto policy

    Crypto Confusion and Problematic Policies of buying cryptocurrencies

    crypto gpu mining

    Cryptocurrency Trend: How GPU Shortage Is Affecting The Mining?

    keep bitcoin safe

    Keep Your Bitcoins Safe: All You Need to Know About Crypto-Cyberthreats

    featured image

    A Beginner’s Guide to Bitcoin futures trading

    crypto traders 2021

    Top 5 Crypto traders to follow on Twitter in 2021

    featured image

    Bitcoin IRA – Everything You Need to Know

    featured image

    How Bitcoin can be hacked?

    featured

    A starter guide to Bitcoin Options trading

    Featured Image

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

    Trending Tags

    • Altcoin
    • Crypto Lists
    • Crypto Market
    • Guide
    • NFT
    • DEFI
    No Result
    View All Result
    • Blockchain
    • Bitcoin
      crypto policy

      Crypto Confusion and Problematic Policies of buying cryptocurrencies

      crypto gpu mining

      Cryptocurrency Trend: How GPU Shortage Is Affecting The Mining?

      keep bitcoin safe

      Keep Your Bitcoins Safe: All You Need to Know About Crypto-Cyberthreats

      featured image

      A Beginner’s Guide to Bitcoin futures trading

      crypto traders 2021

      Top 5 Crypto traders to follow on Twitter in 2021

      featured image

      Bitcoin IRA – Everything You Need to Know

      featured image

      How Bitcoin can be hacked?

      featured

      A starter guide to Bitcoin Options trading

      Featured Image

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

      Trending Tags

      • Altcoin
      • Crypto Lists
      • Crypto Market
      • Guide
      • NFT
      • DEFI
      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
      8
      SHARES
      104
      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

       

      Hitesh Malviya

      Hitesh Malviya is the Founder of ItsBlockchain. He is one of the most early adopters of blockchain & cryptocurrency enthusiast in India. After being into space for a few years, he started IBC in 2016 to help other early adopters learn about the technology.
      Before IBC, Hitesh has founded 4 companies in the cyber security & IT space.

      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
      Share3Tweet2Share1

      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 curate the best cryptocurrency projects with the intention of adding value for investors through the process of selecting, organizing, and looking after different projects available in the cryptocurrency market.

      • Trending
      • Comments
      • Latest
      Top 10 Low Cap NFT Crypto Projects to Invest in 2021

      Top 10 Low Cap NFT Crypto Projects to Invest in 2021

      April 9, 2021
      Top 10 NFT Crypto Projects You Should Know

      Top 10 NFT Crypto Projects You Should Know

      March 12, 2021
      TOP 20 DEFI

      Top 20 DeFi Crypto Projects to Invest in 2021

      April 8, 2021
      Top 10 Cheap Cryptocurrencies with Huge Potential in 2021 | Best Penny Crypto Coins

      Top 10 Cheap Cryptocurrencies with Huge Potential in 2021 | Best Penny Crypto Coins

      March 26, 2021
      Top 25 Cryptocurrencies to Invest in 2021

      Top 25 Cryptocurrencies to Invest in 2021

      April 4, 2021
      top altcoins april

      Top 10 Altcoins to buy in April 2021- Part 1

      April 7, 2021
      hidden gems crypto

      Top 5 Hidden gems Crypto In The Market

      March 13, 2021
      Everything you need to know about Unstoppable Domains

      Everything you need to know about Unstoppable Domains

      April 13, 2021
      upcoming token sales

      Watch out for These Top 5 Upcoming Token Sales

      April 12, 2021
      DEX Comparison: Uniswap Vs Venus Vs PancakeSwap

      DEX Comparison: Uniswap Vs Venus Vs PancakeSwap

      April 11, 2021
      The Rise of Digital Wallet Payments for Online Gaming

      The Rise of Digital Wallet Payments for Online Gaming

      April 12, 2021
      Top 10 Low Cap NFT Crypto Projects to Invest in 2021

      Top 10 Low Cap NFT Crypto Projects to Invest in 2021

      April 9, 2021
      TOP 20 DEFI

      Top 20 DeFi Crypto Projects to Invest in 2021

      April 8, 2021
      INX

      INX- The First-Ever SEC Registered Token Sale

      April 8, 2021
      • Top 10 Cheap Cryptocurrencies with Huge Potential in 2021 | Best Penny Crypto Coins

        Top 10 Cheap Cryptocurrencies with Huge Potential in 2021 | Best Penny Crypto Coins

        12462 shares
        Share 4985 Tweet 3116
      • Top 10 NFT Crypto Projects You Should Know

        5019 shares
        Share 1992 Tweet 1245
      • Top Ten Altcoins You Should Buy in February 2021 – Part 1

        4191 shares
        Share 1676 Tweet 1048
      • Top 10 Low market cap altcoins to invest in 2021

        3632 shares
        Share 1465 Tweet 903
      • Top Ten Altcoins You Should Buy in February 2021 – Part 2

        3539 shares
        Share 1416 Tweet 885
      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
      • DEFI
      • Home
      • Index Test
      • 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.