Editor’s note: this article is a bit of mainland Jiang Jiazhi lecturer, in Denver technology community sponsored technology for developers to block chain guide | JTalk nuggets offline activities fifth edition “sharing activities. JTalk has held 5 sessions, each of which will invite outstanding engineers from vertical industries to share their excellent practical experience, skills and methods. It aims to provide offline technology exchange and interaction opportunities for developers to help them grow.

Jiazhi Jiang, Director of the Bitmain Copernican Project; BCH community senior developer; 10 years of experience in terminal technology and Internet development, developer of Android and iOS clients of Bittoo Wallet; Engaged in the research of the underlying protocol of blockchain, focusing on the research and development of high-performance and distributed systems.

At present, all blockchain projects have a big performance problem, which needs to be overcome from the technical aspect. This is a direction that our team pays attention to. Besides, cryptography is a major driving force for the development of the whole blockchain industry. We also have a task is to put some ideas and research on cryptography into engineering implementation.

When I first got into bitcoin in 2013, I couldn’t sleep every night for nearly two weeks. I thought by 2015, 2016, bitcoin would be available to a lot of people, but after the bear market of ’14,’ 15, I think it’s going to take a few more years. Surprisingly, 2017 saw the massive adoption of blockchain.

Today, I would like to share with you the basic principles and technical aspects of the implementation of blockchain.

1. What is blockchain?

What is blockchain?

Giving a complete definition of blockchain is difficult for two reasons:

There are so many industries involved with blockchain that it is difficult to give it a clear definition. Blockchain basically changes a lot every once in a while, and you can make more interesting things on it.

  • decentralized

    The biggest feature of Bitcoin is its decentralization.

    The adoption of POW, such as bitcoin, Ethereum and so on in the early use of POW, after ten years of proof, POW is the best proof in the implementation of decentralization.

    The emergence of POS and DPOS have sacrificed decentralization to some extent. DPOS uses an election system, and the people you vote for can represent your own ideas, but that doesn’t mean anyone can join the network at will.

    Decentralization has several distinctive features:
    1. Ability to resist censorship. In the whole network activity, corresponding to the whole blockchain is a transaction that will not be rejected for personal reasons, which is anti-censorship ability. Across the network, even if one pool rejects your deal, others will pack it for you.
    2. When a network is down or a node is down due to some irresistible reasons, the entire network is not affected. POW, BCH, BTC, etheric lane has the ability to do this, any mineral pool hang up and the other nodes is still in normal operation, if hang all mineral pools, in the node of the node will set up a new eat again, this may be the whole network capacity decline, but the network is indestructible. DPOS will definitely sacrifice the above two features. If all 21 nodes are blocked, recovery will be difficult (the design of alternate nodes is yet to be confirmed). The 21 nodes also have the ability to censor transactions, making it difficult for anyone to gain access to the network (through elections). I call this weak centralization, after all there are 21 nodes, not a complete centralization. Weak centralization is designed to improve performance metrics, sacrificing decentralization in order to do more.
  • Digital ledger The entire blockchain runs on the Internet
  • Immutable this feature is more obvious in Bitcoin, but in Ethereum, there is a possibility that it can be changed. If a contract is defined, its state can be changed by subsequent trade. But this is more modified and it’s defined before, which means you know that’s what your contract says.
  • Deterministic replication state machines simply mean that all nodes in the network have access to all data.
  • Programmability can be found in Bitcoin. On Ethereum, programmability is further amplified with the language solidity, which is a JavaScript like language.
  • Anonymity because each address/account is on the entire network and does not correspond to someone in the real world. But because bitcoin is a chain of transactions, if you know who the money is going to, you can trace it back to the source. Anonymity is anonymity if you don’t go out into the real world, if you don’t trade with your real identity. If not, the anonymity disappears. That’s why exchanges mandate strict identity authentication for KYC.

How blockchain works

  • Public-private key system
  • Digital signature Recognition
  • Entire network broadcasting
  • Block-recorded transactions are transactions, and each transaction is recorded on the blockchain without recording the actual outcome, and the transactions themselves affect the outcome.
  • Chain structure The whole transaction, the block is a chain structure, everyone will always continue in the same direction, there is no loop or fork.
  • Validation by participants is confirmed by miners in Bitcoin and by super nodes in EOS.

Blockchain features

Blockchain is an asset-based network. No matter what blockchain project you see today, you’re running a network of assets.

  1. Strongly regulated networks include operations such as encryption, signature, authentication, transaction, and confirmation. Any block that does not conform to the rules is rejected as a whole. In Internet projects, when inconsistencies occur, there is a follow-up opportunity for repair and resolution; But in a blockchain, that possibility is very low. If there is a small Bug, the entire network will run problems, will have a great impact on the entire network. In the early days, a few bugs in Bitcoin caused a fork, and the entire network was suspended and then restarted. But if a similar Bug occurs again, it is serious, because at that time, there were few participants in the bitcoin network and the price of bitcoin was low, causing less impact.
  2. Weak trust Each node has a peer. The whole blockchain is understood as a database, and each node has write permission within the system. On a peer-to-peer basis, bitcoin uses computing power to determine who can write more. If you have more resources, if you can mobilize more computing power, the probability of writing is higher.
  3. Trust comes from consensus mechanisms. Non-third party consensus mechanisms include POW, POS, DPOS and DAG. DAG is a consensus mechanism that has been endorsed by cryptographers.
  4. At present, many blockchain projects are developing towards weak centralization. The benefits of weak centralization can also bring about a peer-to-peer trust relationship, and the possible economic value of such trust network may be greater than the value brought by the previous centralized network.

Use of blockchain

  • Digital assets
  • Like Bitcoin, it’s a counterpoint to a trading system. Transfers. Equity stake. Financing. Digital rights. The game. Storage. If the storage is resolved, the above copyright, the game may be in it, including some new applications or new network to generate new value. Be in groping phase at present, whole course of study also somebody does toward these a few directions.

    EatBCHIt’s a Venezuelan project. The collapse of the Venezuelan legal currency, poor relations with other countries, and a blockade in Venezuela have made it difficult to get dollars into the country. The problem is that there is no legal currency to trade with, there is a severe famine in Venezuela, but there is food on the black market. They have a program in China called EatBCH, where they buy food by donating BCH. The whole bitcoin is cross-border, just need to know his address, you can send bitcoin directly to him, cutting out the middle link.

    By taking advantage of BCH’s low-cost network, they can go a long way for just a few dollars without fees. This is a transfer of value networks. The program is estimated to benefit 400 to 500 people in Venezuela. There are similar programs in Africa.

2. Implementation of blockchain technology

Public and private key


Hash

A digital signature


address

trading

The script is running

UTXO and account


  • UTXO without having to maintain balance, because they don’t care what is your balance, only care about what are its lock script, if there is any input corresponding unlock script, so the whole system need not maintain an address, when using a purse, displayed in the address, how many balance is wallet is calculated, to the address below without how many transactions occur, That adds up to your balance.
  • Each UTXO is an independent data record, improving the speed of verifying transactions.
  • UTXO itself does not care about transactions, only locking and unlocking scripts. UTXO can bring great optimization to the whole system in terms of implementation and coding, so it is very easy for Bitcoin to achieve decentralization. In order to run a smart contract in Ethereum, each account should have the ability to store and retrieve data independently. With UTXO, it is not easy to find where data is stored. The account system solves this problem, now every account has a KV storage under it, you can save whatever you want, which makes it easier to use smart contracts.

Block

3. The currency


What is bitcoin?

  • A Peer-to-Peer Electronic Cash System
  • Paper presented by Satoshi Nakamoto, November 1, 2008
  • On January 3, 2009, genesis Block was born (The Times 03/Jan/2009 Chancellor on brink of second Bailout for banks), writing a sarcastic quote, when Britain bailed out The banking system for The second time
  • After 2010, Satoshi himself disappeared and disappeared
  • The total number is fixed at 21 million
  • Coinbase launches bitcoin mining

The wealth that mathematics protects

  • Absolute control of the property, the private key is the only credential, lose the private key will lose everything.
  • Asymmetric encryption algorithm, Hash digest algorithm.
  • Mass accounts, registered with address (public key) ownership, in an almost unlimited supply.
  • Seamless global circulation, where there is the Internet, there is bitcoin.
  • No counterfeit money, natural audit.

The bitcoin system has three major features

  1. Effort to prove POW, embodied in calculate the Hash value to less than the given value, the target is the entire network to maintain, if you count force big, or the target value, certainly cannot satisfy the 10 minutes out of a block, this time will improve the target, the target is more and more big, the need to calculate the force is more and more, This is why the entire network is so large, bitcoin is still maintained for about 10 minutes out of the block.
  2. The chain structure is embodied in blocks and transactions.
  3. Decentralized systems, no one organization can completely block or control the entire network.

dig

Mining is also one of the ways bitcoin is issued, through the Coinbase transaction

  • A large number of random attempts to find the desired number of the process.
  • Proof of work (POW).
  • Coinbase.
  • High returns.
  • Maintain bitcoin’s payment function and package transactions.
  • Big computing power to ensure the security of bitcoin system. In the whole industry chain, the biggest cost is actually miners, miners need infrastructure construction, buy mining machine, the cost is relatively large.

Mining is profit-driven

  • Solve self – growth problems, profit – driven, independent of morality and emotion.
  • Eliminate bitcoin security threats.
  • In the process of calculating power game block chain, evil causes the benefit to decline.
  • Interest binding, organizations with huge computing power, will spontaneously maintain system security.
  • Bitcoin’s long-term growth has made it easier for miners to trade.
  • Big computing power to ensure the security of bitcoin system. Mining is a binding of interests, and the organization with the largest computing power will voluntarily maintain the security of the entire system. The long-term development of Bitcoin is favorable for miners to trade, because miners have a high cost of investment in this area.

The history of mining

The state of Bitcoin

  1. Very disruptive innovation, but still experimental
  2. The currency fluctuates wildly and is not a stable settlement unit
  3. Lack of support from most merchants
  4. The audience is still small
  5. The system’s throughput capacity is still too small to support large-scale transactions around the world (need to be expanded). Bitcoin is innovative, experimental, volatile and not a stable unit of settlement. Bitcoin lacks the support of most merchants and has a small audience. System throughput capacity is small, unable to support large-scale global transactions, so need to expand. Bitcoin has had a hard time expanding and is now divided into BCT and BCH. There will be no further wrangling over expansion now.

Bitcoin expansion history

  • In 2014 Gavin raised the issue of capacity expansion
  • Bitcoin XT (20M, too aggressive)
  • 2016年Bitcoin Classic (2M)
  • 2016 Hong Kong consensus, miners only run Core code, SW appeared for the first time
  • Block expansion is not discussed. Only SW does not directly expand block in roadmap
  • Bitcoin Unlimited appears, with up to 50% power support
  • UASH and UAHF

The etheric fang

4. Ethereum smart contracts

Intelligent contract

  • Nick Saab proposed in the 1990s
  • A computer program that can execute automatically
  • Receive and respond to information, receive and store value, and send information and value outward
  • Turing’s complete language

The etheric fang

  • Intelligent contract
  • Public blockchain platform
  • Ether is its token
  • Ethereum Virtual Machine
  • Peer-to-peer contracts
  • Vitalik Buterin in 2013
  • ICO crowdfunding was developed in 2014

EVM

  • External accounts and contract accounts
    • Each account has a persistent KV storage
    • Transactions are sent from one account to another
    • Include the code code, which will be executed, the transaction related data as parameters
    • The EVM consumes Gas as it executes the transaction
    • EVM VMS are classified into external accounts and contract accounts. The external account is used to transfer money. The contract account contains code that can be executed at each node and takes transaction data as its parameters. If running a long code in contracts, allowing it to have been run, the whole system resources consumption will likely die, so it has a concept of Gas, if you want to run things, have to pay, when to pay the money to deplete, the contract is performed, if finished Gas consumption is not carried out, have the results don’t care, This will ensure that the entire system is safe.

Solidity

  • Solidity is a javascript-like high-level language used by Ethereum
  • Generate the Ethereum VIRTUAL machine code in a compiled manner
  • Each state of the data can be stored permanently
  • Calls that emphasize contract or function execution
  • In the event of an exception, all executions are rolled back
  • The contract is terminated when Gas is consumed
  • Remix requires no browser compiler installation

ERC 2.0

  • ICO
  • ERC20 is a standard set of interfaces
  • Wallets automatically support tokens
  • ERC2.0 is essentially a set of corresponding interfaces that can be adapted to complete the ICO process. The advantage is that if you type Ethereum into the address of the corresponding ICO contract, you can automatically get the replacement coins. This is relatively easy for users, so some people say on the Internet that you can teach you how to issue tokens in 5 minutes.

The cat CryptoKitties encryption

  • ERC721 Token
  • Each cat is a token
  • Every cat is unique
  • Each cat has its own gene crypto cat is also a token, the highest transaction price of crypto cat seems to be more than 100 million, each cat is unique, because nature is a token, and token, it has its own genes, this is the game play.

5. How do I get started

Blockchain industry composition

  • The underlying protocol
  • Ore pool manufacturing
  • Ore pool
  • exchange
  • The wallet
  • In media, the underlying protocol is the most critical. There is a saying that the current underlying protocol architecture is similar to the Internet in 1998, when people made various network protocols, such as HTTP protocol, and so on. In fact, the current blockchain is also similar.

Technically

• Excellent programming skills • Go,C/C• Distributed protocols • databases • compilers • operating systems, kernels • cryptography algorithms

Joining a blockchain enterprise is the best way to understand and learn about blockchain


Above is for developers to block chain technology guide | JTalk nuggets offline activities fifth period lecturer Jiang Jiazhi share, if you are interested in the nuggets JTalk offline activities, can focus on the nuggets page JTalk activities for registration. JTalk has been held for 5 sessions. The monthly JTalk will invite outstanding engineers from vertical industries to share their excellent practical experience, skills and methods. It aims to provide offline technology exchange and interaction opportunities for developers to help them grow.

JTalk forecast

The sixth issue of JTalk will be held in Hangzhou.

  • Topic: From the front end to the back End
  • Time: 5.20