2
头图

Blockchain technology has developed rapidly in China in recent years, and has been explored in many fields and has many applications. As a new type of technology, while blockchain technology helps enterprises improve efficiency, it still needs to release more possibilities in terms of labor costs and alliance chain compatibility.

How to reduce the development cost of blockchain and make it more efficient and convenient to apply to the industry has become the key to enhancing the application value of enterprise blockchain. At present, the blockchain still faces many pain points in the actual application development process.

To this end, on the basis of years of technical research and application practice, WeBank Blockchain has actively analyzed and summarized industry needs, and has developed a set of blockchain application development components WeBankBlockchain-SmartDev, which uses a low-code method without affecting the original On the basis of business, solve the connection problem between the blockchain and the original application.

The original intention of the development of blockchain application development components is to create a low-code development component library to help developers develop blockchain applications efficiently and agilely in all aspects.

This component includes a set of open and lightweight development components, covering contract development, compilation, application development and other links. Developers can choose corresponding development tools according to their own conditions to improve development efficiency.

Including WeBankBlockchain-SmartDev-Contract smart contract library component, WebankBlockchain-SmartDev-SCGP (SmartContractGradlePlugin) smart contract compilation plug-in, WebankBlockchain-SmartDev-Scaffold blockchain application development scaffolding component, etc.

Developer-friendly one-click application development scaffolding, contract templates and other functions facilitate the development of blockchain applications, allowing the development process to move towards a "low code" model.

Features and principles of blockchain application development components

This application development component has been planned since the beginning of 2020, and there have been various problems in the development process of DAPP. In the process of solving these problems, we have accumulated some experience. We have successfully reused these experiences in application development components. Let's take a look at the characteristics and principles of application development components.

  • The first is the smart contract library , which contains the basic type layer, the structure data layer, the general function layer, and the upper business layer.
  • Basic type layer: It includes mathematical operations, string-related operations, array operations, and address operations.
  • Data structure layer: it contains some data structures, such as iterable mapping, linked list, etc.
  • General functional layer: It contains some crud contracts and some cryptographic operations.
  • Upper business layer: contains business templates such as traceability and certificate deposit.

The second is the contract compilation plugin. The traditional operation method is to upload the contract to the console, run the script, and then copy the content of the contract. The frequent compilation and debugging process takes a lot of time. The contract editing plug-in only needs to execute simple instructions, automatically generate and place it in the designated location, without making additional copies.

According to the current environment, the component selects the corresponding jar package, reads the Solidity file and compiles it, and the compilation will output three contents, namely ABI, BIN, and Java contract. Among them, ABI is the interface, the interface definition of the smart contract; BIN is the contract binary, which contains the binary of the national secret version and the binary of the non-national secret version; the Java contract includes the way to call the smart contract interface through Java.

The last is application development scaffolding, which generates a common DAPP project structure.

First, it contains some resource files related to the contract, ABI and BIN.

The second is the code, which can be divided into two parts: connection, config, and utils. These are used to connect the blockchain and FISCO BCOS.

Followed by service and POJO. The service corresponds to the call of the smart contract, and the POJO is the function input of the smart contract. The service method corresponds to the function in the smart contract. Calling the service method will automatically perform assembly transactions and receipt analysis.

The principle of scaffolding includes the following points. First, perform some general tests, then generate template files, compile smart contracts, parse each function of each contract of the ABI, read its parameters, and assemble it into the corresponding Java class. Finally, the build of the project is generated.

图片

Blockchain application development component tools practical operation

Practical demonstration can be enjoyed with video playback
https://www.qq.com/video/m32541bybxl

First visit the smart contract library address, which includes the upper-level business, basic types, data structure, and general function layer. You can see some library files and some demos, which is very convenient to call the files in the library.

The second is the actual operation of the contract compilation plug-in. The contract editing plug-in is actually very simple to use. First, open the official document, configure builg.gradle for dependencies and other configurations, and then execute gradle solc. The plug-in will read the hello world contract of the project, and it will read from the contract by default. Contract, and then generate ABI and Java contracts.

Finally, there is a demonstration of application development scaffolding. Copy the scaffolding code first. Enter the tools directory, the contract has been placed by default in contract, and then config.ini, where you can define some commonly used content, such as project name, group group, compiler version, solidity version, etc. We can change these content as needed . In windows and UNIX environments, a bat file and shell file will be provided.

Let's take a look at the generated project. This is a springboot project, which has corresponding dependencies, including Java SDK, springboot, etc. From the generated code, the core code is hello world service, which corresponds to the hello world contract, and service corresponds to the set and in the contract. The get function calls the set function or the get function to call the corresponding smart contract.

As you can see from the resource directory, it contains the input and output of the smart contract. At the same time, there is also a conf directory to help you drag down some certificates on the nodes of the chain and put them in the conf directory. Application and properties are relatively standard configuration files of springboot.

As you can see from the test directory, there are some commonly used functions in the test, such as generating a private key and deploying a contract. Developers can put these functions into the demo according to their own ideas. This is the demo project generated by the scaffolding, which contains many functions with smart contracts as the core.

Finally, everyone is welcome to jointly build blockchain application development components. The smart contract library has long-term collection of contract library codes. There are dozens of tasks for everyone to choose from, and you will receive gifts after completing the tasks. Welcome to participate!

Click read the original text participate in smart contract library activities.

Experience WeBankBlockchain-SmartDev:

SmartDev-Contract smart contract library component
https://github.com/WeBankBlockchain/SmartDev-Contract
SmartDev-SCGP contract compilation plugin
https://github.com/WeBankBlockchain/SmartDev-SCGP
SmartDev-Scaffold application development scaffolding
https://github.com/WeBankBlockchain/SmartDev-Scaffold

"Super Talk
"Super Talk Blockchain" is a live broadcast event launched by the FISCO BCOS open source community. Every Thursday at 8 pm, the community invites a technical geek or application pioneer to share development practices or application experience in the live broadcast room. As a fixed column in the community, "Super Talk Blockchain" has held nearly a hundred sessions, covering everything from technical seminars to industrial applications. You are welcome to recommend yourself or recommend friends to share in the live broadcast room. Add a small assistant to the group to watch the live broadcast.

The code of FISCO BCOS is completely open source and free
Download link↓↓↓
https://github.com/FISCO-BCOS/FISCO-BCOS


FISCO_BCOS
193 声望1.3k 粉丝

FISCO BCOS是开源联盟区块链底层技术平台,由金融区块链合作联盟(简称金链盟)成立开源工作组通力打造。成员包括博彦科技、华为、深证通、神州数码、四方精创、腾讯、微众银行、亦笔科技和越秀金科等金链盟成员机构。