Smart contract
Programming language
Use golang as a programming language (with restrictions on some keywords to ensure orderly processing), instead of recreating the programming language.
golang is a simple, easy-to-use programming language with comprehensive help documentation and development tools.
It is strongly type-checked, and many bugs can be found during compilation.
It is modular, and the system can simply shield external functions, making smart contracts in a simple and predictable environment.
There are already a lot of golang developers who are very easy to get started if they want to develop smart contracts.
Classification of smart contracts
Public-private
Public contract : It uses the code of the contract and calculates the hash as the name of the contract. Its account is a public account.
Private contract: It uses the code hash of the contract and the second hash of the user account as the name of the contract, so different people create different private contracts with the same code. Its account is the creator's account, allowing the contract Operate the account.
As long as it is the same code, the published public contract has the same name.
Contracts of the same code have the same name on different chains and support cross-chain access to Log information of the same contract.
Functional division
Executable contract: This contract allows users to call it. The contract has an execution entry. By default, anyone can call the contract.
Referenceable contract : This contract can be imported by other contracts, thus forming a more powerful contract.
A contract allows both functions.
Smart contract description
The system requires that the contract releases all source code, and anyone can see the content of the source code. It is easier to view and understand than the compiled binary program.
After the smart contract is released, all the code logic is fixed. By understanding the code, you can trust the smart contract more.
All contracts can only import other contracts on the chain. Modules outside the chain are not allowed to be imported. System modules that import golang are not supported. Some keywords that will cause the program to be out of order will be banned, such as go, select, rang, recover, cap.
Each chain contains the same system contract, through which data can be read and written (stored), transfers, etc. Public contracts can only import public contracts, thus ensuring that anyone can publish public contracts to other chains. Private contracts allow importing any contract without restrictions.
The published contract will be compiled into a program on each node, which can be called by users.
The execution of the contract needs to consume Energy, which is the token. Its consumption is determined by the number of lines of code executed by the contract. When a contract is compiled in a node, it will be dynamically increased by code line coverage statistics.
Reading information across chains
Smart contracts can read information across chains through Log objects. The interface is provided by the system contract and supports reading information across multiple chains. The information read is written by the same contract on another chain.
The log time difference must be greater than n * 5 minutes. The time difference is the current block time-log write time; n is the logical distance between the current chain and the log's chain (the distance from one point to another on the binary tree). If the time is not met, a null value is returned.
Performance and scalability
The executable contract will eventually be compiled into an executable file, which has a higher execution efficiency. The TPS performance limit of a smart contract on a chain depends on the TPS performance of the chain, and the contract performance on a single chain theoretically approaches the performance of the chain in which it is located.
Smart contracts are published on different chains and use multi-chain parallel processing mechanisms to achieve the expansion of the overall performance of smart contracts.
The smart contract can realize the cross-chain transfer of data through the cross-chain reading function of Log.
So the ultimate performance of a smart contract is the performance of the entire system.