Getting Started with Blockchain Programming

The blockchain is so popular, but you will soon find that if you want to get started with blockchain programming, especially if you want to learn blockchain programming from scratch, you can't find a breakthrough at all!

So, to master blockchain development technology, what knowledge and programming languages ​​should you learn to quickly get started with blockchain programming?

If you want to start learning Ethereum blockchain application development right away, you can visit the excellent online interactive tutorial provided by Huizhi.com: -Ethereum Application Development Introductory Tutorial
- Ethereum Decentralized E-commerce Application Development Practice

what is blockchain

What is blockchain? In a word, it is an implementation of a special distributed database technology.

First, the main role of the blockchain is to store information. Any information that needs to be saved can be written to and read from the blockchain, so it is a database.

Second, anyone can set up a server, join the blockchain network, and become a node. In the world of blockchain, there is no central node, each node is equal and holds the entire database. You can write/read data to any node, because all nodes will eventually be synchronized to ensure the consistency of the blockchain.

Distributed databases are not new inventions, there are already such products on the market. However, blockchain has a revolutionary feature.

The blockchain has no administrator, it is completely centerless. Other databases have administrators, but blockchains do not. If someone wanted to add auditing to the blockchain, it wouldn't be possible because it was designed to prevent the emergence of a central authority.

It is precisely because it cannot be managed that the blockchain can be uncontrollable. Otherwise, once the big companies and groups control the management, they will control the entire platform, and other users will have to obey them.

However, without the administrator, everyone can write data into it. How can we ensure that the data is trustworthy? What if the bad guy changed it? Read on, that's the magic of blockchain.

So, what is a block?

A blockchain consists of blocks. Blocks are much like database records. Every time data is written, a block is created.

Each block contains two parts.

  • Block header (Head): record the characteristic value of the current block
  • Body: actual data

The block header contains a number of characteristic values ​​of the current block.

  • Generation time
  • The hash of the actual data (i.e. the block body)
  • the hash of the previous block

Here, you need to understand what a hash is, which is necessary to understand the blockchain.

What is a hash?

The so-called "hash" means that a computer can calculate a characteristic value of the same length for any content. The hash length of the blockchain is 256 bits, which means that no matter what the original content is, a 256-bit binary number will be calculated in the end. And it can be guaranteed that as long as the original content is different, the corresponding hash must be different.

For example, the hash of the string 123 is a8fdc205a9f19cc1c7507a60c4f01b13d11d7fd0 (hexadecimal), which is 256 bits in binary, and only 123 can get this hash. (Theoretically, it is possible for other strings to get this hash, but the probability is so low that it can be approximated as impossible.)

Therefore, there are two important corollaries.

  • Inference 1: The hash of each block is different, and the block can be identified by the hash.
  • Corollary 2: If the content of a block changes, its hash must change.

Why is it called blockchain?

There is a one-to-one correspondence between blocks and hashes, and the hash of each block is calculated for the "block header" (Head). That is to say, the feature values ​​of the block header are connected together in order to form a very long string, and then the hash of the string is calculated.

Hash = SHA256( 区块头 )

The above is the calculation formula of the block hash, and SHA256 is the hash algorithm of the blockchain. Note that this formula only contains the block header, not the block body, that is to say, the hash is uniquely determined by the block header,

As mentioned earlier, the block header contains a lot of content, including the hash of the current block body and the hash of the previous block. This means that if the content of the current block body changes, or the hash of the previous block changes, it will definitely cause the hash of the current block to change.

This has major implications for blockchain. If someone modifies a block, the hash of that block changes. In order for subsequent blocks to still be connected to it (because the next block contains the hash of the previous block), the person must modify all subsequent blocks in turn, otherwise the changed block will be removed from the blockchain . Due to the reasons mentioned later, the calculation of hash is time-consuming, and it is almost impossible to modify multiple blocks in a short period of time, unless someone masters more than 51% of the computing power of the entire network.

It is through this linkage mechanism that the blockchain guarantees its own reliability. Once data is written, it cannot be tampered with. It's like history, what happens is what happens, and it can't be changed from now on.

Each block is connected to the previous block, which is where the name "blockchain" comes from.

Suitable application scenarios for blockchain

We all know that there is no silver bullet in technology, and neither is blockchain.

As an unmanaged distributed database, blockchain has been running for 8 years since 2009 without major problems. This proves that it works.

However, in order to ensure the reliability of data, blockchain also has its own costs. One is efficiency, data is written to the blockchain, and it takes at least ten minutes to wait. It takes more time for all nodes to synchronize data; the other is energy consumption, the generation of blocks requires miners to perform countless meaningless calculations, which is Very energy consuming.

Therefore, the blockchain has its own applicable scenarios:

  • There is no management authority trusted by all members
  • The written data does not require real-time usage
  • The income of mining can make up for its own cost

If the above conditions cannot be met, then a traditional database is a better solution.

Blockchain platform selection

If you want to learn blockchain development, you first need to choose a suitable blockchain platform. At present, the blockchain has 1.0 and 2.0.

Blockchain 1.0

It is mainly composed of digital currency and payment behavior. Features include:

  • Chained data block structure in blocks;
  • shared ledger;
  • Asymmetric encryption;
  • source code open source

Blockchain 1.0 mainly has the functions of a decentralized digital currency and payment platform; the goal is to decentralize, and the typical representative is Bitcoin. Blockchain 1.0 is not very developer friendly.

Blockchain 2.0

The main feature is to support smart contracts and decentralized application development.

  • Smart contract: The application in the blockchain system is the coded business logic that can run automatically, usually with its own token and special development language;
  • Decentralized applications: DApps, applications that contain user interfaces, including but not limited to various cryptocurrencies, such as ether wallets; virtual machines, which are used to execute the compiled code of smart contracts, and the virtual machines are Turing-complete. Smart contracts have begun to be applied on the blockchain, replacing manual operations with machine contract instructions, making everything more transparent, and no one is manipulating and interfering. For example, ICO on Ethereum greatly reduces financing costs.

Therefore, Blockchain 2.0 is a developer-friendly blockchain platform. Ethereum is a typical representative of blockchain 2.0.

Blockchain development language selection

The choice of development language depends on what you want to do.

If you want to implement a blockchain platform by yourself, you can choose any development language, such as: java, c/c++, python, nodejs, go…

If you want to carry out the underlying transformation of the existing blockchain platform, it depends on what the mainstream development language of this platform is. For example, the most popular version of Ethereum's underlying protocol implementation is the go language, then you can learn go.

If you want to develop applications based on the existing blockchain, then it depends on the constraints of the platform. For example, the mainstream development language for smart contracts on Ethereum is solidity, and the development languages ​​for decentralized applications are nodejs and html/javascript/css.

Therefore, for engineers who want to learn blockchain development technology, starting with Ethereum application development is the best way to get started with blockchain development. If you already have a web development foundation, you only need to understand the concept and function of smart contracts first. , and then learn solidity to develop the smart contract of the Ethereum blockchain, combined with the web front-end, you can quickly develop a blockchain-based decentralized application!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324769395&siteId=291194637