Summary: The inline assembly language embedded in solidity, described above, can also be used alone. In fact, it is an intermediate language that is intended to be used as a compiler. in this paper, we will introduce the development specification and development process of solidity language in the process of developing intelligent contract.
Solidity is an intermediate language for compilers. Developing smart contracts requires adherence to the appropriate development specifications and development processes.
Development specifications
Naming Conventions
Directories and files
- The directory uses lowercase, do not use special symbols;
- The library file and the contract file are unified with . Sol as the suffix;
- The contract file name remains the same as the contract name;
- The file name is named after the Hump (capitalized);
Contract, library file naming
- the name of the contract is named after the Hump (first character capitalization), for example: Usermanager, ActionManager;
- the name of the method uses the Hump method (the first letter lowercase), for example:getnumber;
- the name of the property uses the Hump method (lowercase), for example:userName;
- A function or method that starts with a double underscore is called as an internal contract method;
- The contract library name prefix lib+ structure names, such as: Libuser, libaction;
Constants and configurations
- constants are named with uppercase letters and underscores, for example App_path;
- configuration parameters are named with lowercase letters and underscores, such as url_route_on and Url_convert;
directory Structure
|-app (Truffle service catalogue) |-contracts (contract directory) | └─interfaces (Abstract contract directory) | | └─LIBRARY (Structure Analysis library directory) | | └─sysbase (Public contract directory) | | -ownernamed.sol (basic contract, all user business contract, must inherit this base contract) | └─basemodule.sol | | └─utillib (Tool library catalog) | | -libdb.sol| | -libdecode.sol| | -libint.sol| | -libjson.sol| | -liblog.sol| | -libnizk.sol| | -libnizkparam.sol| | -libpaillier.sol| | -libstack.sol| | -libstring.sol| └─strings.sol| | -migrations (Truffle Release configuration directory) |-test (test script directory) |-truffle.jscopy
In general development, the functionality of contract files is categorized by using a catalog, which describes the following features:
- Contracts Truffle Standard working directory of the contract directory, the contract is stored in this directory, such as: Usermanager.sol;
- Interfaces deposit abstract contracts, such as: Iconsumermanager.sol;
- The library holds the structure database file of struct;
- Sysbase stores the directory of public contracts, for example: Ownernamed.sol;
- Utillib Storage Tool Library, such as: Libstring.sol, Liblog.sol;
Development process
- Contract Interface Definition
According to good programming habits, before writing the business method, first define the interface and deliver it to the caller.
- Data structure definition
in a user-defined contract interface, if there is more complex input /output data, it is necessary to define some data structures in advance, and provide some common methods of manipulating these data structures (mainly, some methods of serializing JSON strings).
- Business Contract Preparation
Implement the Contract interface definition and implement the user's business logic. In the constructor of the business contract, the business contract needs to be registered in the module contract.
If the user just wants to write a business contract, do the study, test, you can register the business contract in the "Juzix.io.debugModule" the special name of the module contract, then the user can not need to write a module contract, The method of calling the business contract directly in the juice client IDE.
write the module contract, which is Juice The requirements of the Open service platform to manage users ' dapp applications and business contracts. In the constructor of the module contract, you need to register the module contract with the chain and describe in the constructor all the business contracts that the module contract will use.
the user has written the module contract and deployed it to After juice the blockchain, the module name will be displayed in the "My apps" of juice Open service platform, click on "My Apps" app, will jump to the user open Dapp app. How to set the app's Jump URL, reference module contract writing HTTPS://OPEN.JUZIX.NET/API_DOC/PART03/EXAMPLE/MODULES.MD
- Compiling the deployment, testing
through The juice client, or the online IDE, can compile, deploy, and test the user contract.
Content reference:https://open.juzix.net/doc
Smart Contract Development Tutorial Video: http://edu.51cto.com/course/13403.html
Smart contracts from beginner to proficient: solidity language development specification and development process