HNB Tech Part III: Smart Contract

HNB
HNB News
Published in
3 min readFeb 25, 2019

Like other public chain ecosystems, DApp is one of the core features of HNB’s decentralized economic community. In the HNB blockchain underlying core system, the DApp is composed of user APIs and smart contract. DApp’s backend coding is realized by smart contracts. The front end can be any end-user applications, such as HTML5, mobile app, WeChat applet, etc., via the provided APIs to interact with the back-end smart contract to achieve HNB’s specific business application processing.

The smart contract of the HNB blockchain system supports golang and JavaScript languages. So that developers of smart contracts do not need to learn new languages and lower the barriers for merchant access. Using golang as the execution environment for smart contracts, smart control logic can be implemented for the HNB application layer framework. The golang virtual machine has Turing completeness, can implement arbitrary logic, and is highly deterministic, which is very suitable for commercial business scenarios with high deterministic requirements.

HNB adopts the self-developed HNB-VM virtual machine platform. HNB-VM performs deep optimization on the execution of instruction code parsing, which improves the execution efficiency of instructions while ensuring security. HNB-VM features are as follows:

1. High-Speed Cache Access: HNB-VM creates a multi-layer cache and designs a cache structure according to the probability of occurrence of the instruction code, which improves the cache hit probability and reduces the number of times of calculating and reading the object address data.

2. Instant compilation: The traditional virtual machine platform is interpreted as a series of operations such as stacking, popping, reading and writing variable areas, and reading method areas. These operations could seriously affect the efficiency of virtual machine interpretation. HNB will compile the contract hotspot program in real time, reducing the operation steps of the registers.

3. Storage structure optimization: Optimize the object storage structure, establish the mapping relationship between the object identifier and the storage address, and realize efficient retrieval of the object storage address. At the same time, optimize the attribute information in the object structure to improve the memory resource utilization.

Regarding the security concerns for the smart contract, we’ve also designed and implemented a comprehensive mechanism to ensure security. HNB technical team believes that reinforcing smart contract audit is an important guarantee for improving the security of blockchain, and formal verification is an effective method to address the smart contract audit requirements. The formal verification of HNB is based on the established formal specifications, and analyses and verifies the relevant characteristics of the specified system to judge whether the system meets the desired characteristics. Formal verification does not completely ensure that the performance of the system is correct, but it can maximize the understanding and analysis of the system, and find errors such as inconsistency, ambiguity, incompleteness and so on.

In the aim to serve the real economy, and based on the HNB blockchain system and the distributed application DApp supported by smart contracts, the HNB team can help to achieve the cooperation, co-building, co-governance among all the members of the HNB commercial community, and build a decentralized autonomous organization. In the near future, we will accelerate the flow of resources and optimize the allocation, promote the development of the economy, and create a better life for people.

Code Snippets:

Follow us on Twitter to stay up-to-date with our latest announcements. Join our official HNB Telegram group to join the conversation with our community and team members.

HNB.ECO team

--

--

HNB
HNB News

Empowering global enterprises through a decentralized blockchain economy 🌍 ​ https://hnb.eco/