Blockchain (1.0) is a cryptographic-based distributed ledger that is easily verifiable and immutable. It is generally considered that the blockchain combined with smart contracts is blockchain 2.0. For example, Ethereum is a typical blockchain 2.0. Many people only know about Bitcoin, but do not know about blockchain. Blockchain is the future. I hope developers care less about currency price and more about technology. This article will explain how blockchain 1.0 technology is implemented.

The hash function

Before we talk about blockchain bookkeeping, let’s talk about hash functions. The raw information can be any information, and the Hash results in a short summary

Hash functions have several characteristics:

  • The same original information and the same hash function always get the same summary information
  • Any slight change to the original information hashes out an unrecognizable summary of the information
  • The original information cannot be back-inferred from the abstract information

For example: Hash(Zhang SAN lends Li Si 1 million yuan, 1% interest, principal and interest will be repaid after 1 year… ..) There is such a record as AC4635D34DEF in the books.

You can see that the hash function does four things:

  • The simplified message is easy to understand, the hashed message is shorter.
  • Identifying information can be identified by AC4635D34DEF as the original information, and summary information is also called the ID of the original information.
  • Hidden information ledger is a record such as AC4635D34DEF, the original information is hidden.
  • Verify information If Li Si deceives in repayment that Zhang SAN only lends Li Si 100,000, both parties can use AC4635D34DEF to verify the original information

These four functions of hash function are widely used in blockchain technology. (A hash function is a group of functions or algorithms that will be covered in a future article.)

Blockchain accounting method

Suppose there is an account page with account number 0 and the transaction record is as follows:

account booked Enter an item of expenditure in the accounts The balance of descr
The king 2 100   190 Receiving payment for XXX
Zhang SAN   100 30 xxxx
Li si 120 90 170 xxxx

The accounting time is: 2017-10-22 10:22:02

In accounting, blockchain will Hash account page information (including serial number, accounting time, and transaction record) as the original information to get a Hash value, such as 787635ACD, which can be expressed as the function:

| ` ` ` HTML Hash (serial number 0, time of charge to an account, transaction records) = 787635 acd

| -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - | ZhangYe information and Hash value together constitute the first block. < p style = "max-width: 100%; clear: both; min-height: 1px; | ` ` ` HTML Hash (on a Hash value, the serial number 1, time of charge to an account, transaction records) = 456635 BCD ` ` ` | | -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - | Thus the second block contains not only the page information, but also the information of the first block indirectly. If this method continues in turn, the latest block always indirectly contains all the previous page information. All the blocks are combined to form the chain block, this block chain will constitute a convenient for validation (as long as the validation of the last block of Hash value is equivalent to validate the entire book), cannot be changed (any transaction information of the change, can let all blocks Hash value after the change, when the validation so cannot pass) of the total books. Accounting cost, want to understand why the node to an account, please look at this article: in [COINS how to dig - work certificate] (https://learnblockchain.cn/2017/11/04/bitcoin-pow/) *! [](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/a78ddb00b8544e6a90c2d01dd50a9c2f~tplv-k3u1fbpfcp-zoom-1.image)Copy the code