What is blockchain

About what blockchain is , There are so many explanations on the Internet . here , Let me summarize from the perspective of general needs : In record keeping ( ID card ) when , It's a distributed ledger ( Distributed database ); In trading or paying ( Cross border payments ) when , It's trusting the machine . Although the two classification methods are not orthogonal , But it's good for understanding the application field of blockchain .

Whether it's distributed ledger , Or trust the machine , The characteristics of its bottom layer —— No tampering 、 transparent 、 Traceability and decentralization , There is only one ultimate goal , That's trust .

The credibility of blockchain comes from human's trust in the strictness of mathematical logic , Mathematical theory and cryptography practice can ensure the reliability of data and ownership on the chain . Block validation is based on consensus algorithm 、 Immutable data structure , Re pass  Merkle Tree、Hash Pointer( Hash pointer ) Guarantee the integrity of the forward blockchain , Plus the economy 、 The game of hearts 、 Rational economic man hypothesis , Together to form a complete trust system .

However , There are some differences in the alliance blockchain between enterprises , Its trust depends more on the endorsement of the sponsor's brand . In this environment , The design of alliance chain becomes quite flexible , For example, the token was the first to be cut .


Industry application of blockchain

In the latest release of the Ministry of industry and information technology 《2018 White paper on China's blockchain industry 》 in , The industrial ecology of blockchain is divided into industrial applications ( It covers the financial and physical fields ), Infrastructure and platforms ( Such as the public chain and BaaS), The service industry ( Such as media ). And our focus is on industrial applications .

The financial sector is highly digitized , In Securitization and ABS There are landing cases in exchanges and other directions . In the real industry , Supply chain traceability , There are also many applications such as ID card . In addition, blockchain itself has “ Trust penetration ” The magic effect of , For the construction of supply chain financial credit system , It is also helpful to improve the financing difficulties of small and micro enterprises .

On the whole , Blockchain technology can be applied in almost all kinds of industrial scenarios , Because there are efficiency improvements in these scenarios , cost reduction , The demand of optimizing credit reference system .


Application of auto finance blockchain

Auto Finance

The core asset of automobile finance is automobile . Auto finance always revolves around the life cycle of cars . From the production of spare parts , Go to the main engine factory to manufacture the whole vehicle , And then sell the whole car to the dealers in each region through the sales companies in each region . Actually in China , Dealers can also be divided into two or three levels of dealers , Finally, it's in the hands of the customers . And once the new car is sold , It has entered the vast world of post market , And used cars 、 The resale of tricycles .

From the production, transportation and assembly of auto parts to selling to dealers , The financial activities involved in these links are called supply chain finance , And customers buy cars through financial activities , Whether it's a new car or a used car , They all belong to the category of consumer finance .

The life cycle of cars and the involvement of financial companies :

Their business model looks like this :

 picture

By analyzing the existing business model in the industry , We found that :

High cost of financial reconciliation , And low efficiency . The financial cost here is not the financial cost of a company , It's the total financial cost of the whole system . There may be many sales companies and financial companies in China alone , And hundreds of dealers , Even if each company has only two finance and audit staff , So financial auditors are more than 1000 , Not to mention global sales .

What is the traditional way of reconciliation ?

Different types of institutions carry out reconciliation , It is often necessary to export electronic forms from information systems , And send it by email . You even need to print forms 、 Stamp and mail , The other party will compare with the system data after receiving it .

The whole business process is not complicated , But it costs a lot of human and material resources , And the centralized service is also due to the authorization mechanism ( There is not much trust or weak trust between multiple agents ) And information security , And lead to high construction costs , It also restricts the improvement of business operation efficiency and user experience . Blockchain as a distributed ledger , It means that the information of debt transactions between any institutions is consistent , Then reconciliation can be done in near real time .

And what we're going to do with blockchain , In a word , The record of the automobile assets on the chain and the debts generated by the financial activities around the automobile . So it's not hard to find , Both distributed ledger and trust machine are involved in this scenario .

How to build a chain

We summarize the process of building the chain as 5 A step : Identify the linked data , Smart contract design ,API Design , Deployment unit and network topology .

  • Identifying data on the chain refers to identifying which transactions are recorded on the chain ;

  • Smart contract design , It refers to how the sale and purchase of cars and related financial activities can be automatically completed in a programmable way ;

  • API Design , Consider how to expose platform capabilities to the outside world , At the same time, control subjects are limited ;

  • Deployment unit and network deployment architecture belong to the scope of implementation , The purpose of this paper is to find out how the distributed ledger really works in the enterprise .

The overall technical architecture is based on Corda This distributed ledger technology starts ,Corda It's not exactly blockchain , It's a blockchain inspired DLT, Distributed ledger technology , It's created by the financial blockchain Alliance R3 Developed and maintained .

Online data identification

The problem to be analyzed is when the car will move , What kind of participants does the car move between , What data changes are accompanied in the process of car transfer . When analyzing this business , We go through the storm of events , This paper analyzes the business events of vehicle transfer between various legal entities , And then we sort the events , Precipitation of data through events , Including trading participants , Details of the car , Ownership and possession of the car and debt, etc . There are some trade-offs in this part of the data , For example, orders are not among our core assets , So not on the chain .

 picture

We started to model the data , Before that , It is necessary to introduce Corda Programming model ——State, Because it will directly affect our subsequent model design .Corda One of the core concepts in this book is State,State It's a fact in the distributed ledger , It represents the result of a consensus among the participants in the transaction . With IOU Take this IOU as an example ,State In fact, it is a collection of key attributes of IOU , Including the borrower , Debtor , The amount of money , Repayment deadline . When part of the debt is returned , The content of this IOU will change , The way to change is to mark the old IOU as historical , And then generate IOU with new content .

 picture

In our application scenario , The core State It's cars and debt , because Corda Is running on the JVM On , The preferred language for development is Kotlin, So here we go straight to Kotlin in data class Modeling cars and debt , And unified inherits Corda Built in LinearState,LinearState Have global uniqueness ID, It doesn't change in the process of data evolution . If anyone understands DDD Related concepts , It should be automatically mapped to entity concepts . besides ,Corda There's also a core in this State be called Fungiable Asset, It's analogous to a value object , for example :Cash.

State How to evolve after modeling is completed ? I have to mention one UTXO The concept of ,UTXO Full name unspent transaction ouput, It started with bitcoin , It has many advantages , For example, we can trace back to the source of every output , Help to verify the existence of double flower phenomenon ,Corda The same inherits similar benefits . When the sales company wholesales the car to the dealer , Will take the ownership of their own car as an input to the transaction , To produce output , The output includes the change of ownership and the generation of debt . And the car as input will be marked as historical . The deal itself has to be signed by both sides of the deal .

Smart contract design

What we talked about above is the data on the chain and the data evolution process , But none of these processes are automatic . For complex financial contracts , It often involves a variety of state The change of , At this point, you have to encapsulate these changes with automated processes , What encapsulates these changes is actually a smart contract . Let's take wholesale cars from dealers as an example , A possible contract template is to stipulate that a debt will be generated when the car is transferred , And the corresponding repayment deadline . This contract enforces state When the change , Both parties to the transaction must sign .

Before we go into smart contract implementation , We need to know something about Corda in flow and contract The concept of .Flow yes Corda Control how the participating nodes are updated State The automated process , It encapsulates how to get signatures from counterparties . A standard flow The process includes getting data on the chain , Create a deal , After signing, it is sent to the opposite party for transaction verification , Sign again , Finally, the transaction will be submitted on the account books of both parties . and Contract The script used for verification is provided in the transaction verification phase .

 picture

In our application scenario , Smart contracts look like this , stay flow in , Take the data of the original car from the chain first , Copy to get a new ownership transfer car and corresponding debt ; And then through txBuilder Build a deal , The input to the transaction is the original car , And the output is new cars and debt ; Finally, the process of verification, signature and transaction commit . You may have noticed txBuilder There was a firstNotary Parameters of , Just to mention here notary The concept of ,notary stay corda Is a special kind of node , It is specially used to prevent the problem of double spending of assets . So theoretically , Every deal needs notary Nodes participate in , And sign the deal . In the process of transaction verification , We define contract Will be performed , This contract It's simple , It's as simple as one called verify The pure function of . Its function is to assert that every state Whether the update of is up to the requirements . This design fits very well with Trust But Verify Idea .

 picture

API Design

With smart contracts , We have to consider how to expose the contractual capabilities of the platform . let me put it another way , From the perspective of consumers , How can we use the capabilities provided by the platform to complete our business . So here we use REST api Design ideas , Abstract the capabilities of the platform and present them as resources , Define car centered URI, Then choose the right one HTTP Verb , obtain REST api.

 picture

Identify from the data link , To smart contract design , Until then API Design , We use... At different levels Corda This distributed ledger Technology . The bottom distributed ledger records the facts of each transaction , Not tamperable, traceable ; The smart contract layer in the middle provides contract abstraction , It can even correspond to the real contract one by one ; The top one REST api It presents the financial activity ability of the platform in the form of resources .

 picture

Deployment unit

How does such an auto finance platform come into being ? With the help of Docker, We package a physical deployment unit into a mirror , The bottom layer is a fully functional Corda node , All the smart contracts and state Are subject to jar The package is deployed on this node ; Simultaneous utilization SpringBoot adopt RPC To connect to Corda node , Call smart contract , External exposure REST API; and Corda Nodes communicate with each other through messages .

 picture

Network topology

Pack it up docker After mirroring , Can be deployed to the running environment , Form a distributed ledger P2P The Internet . Here you are 2 You need to pay attention to , The leftmost permission service It is used to issue certificates to each network node , Give each participating entity an identity . In the middle of the Network map It's similar to service discovery,Corda The mutual discovery of nodes does not happen through broadcasting , It's through registration Network map Get information about other nodes , And find each other .

 picture


review

Last , Let's review the three-tier architecture above , Reassess the entire platform from a value perspective . Traditional platforms , adopt api To expose services in a way that allows for value input , But the core assets of the blockchain platform are actually in the bottom ledger . Based on these transaction facts and debt or payment records , We can easily liquidate the digital assets of various legal entities , Calculate real-time debt information , Tracing the value of the vehicle , And in the future, combining big data analysis and AI, More likely to create a complete supply chain Ecology .

 picture