The operation of the database in CyberVein is finally reflected in the operation called smart contract to the database of CyberVein. For example, Blocks in the chain of traditional smart contract is stored in the entire network state (that is, writing books), when a user needs to deploy a smart contract will be equivalent to perform with local virtual machine code in the book, all calls to smart contract knowledge of users based on the same code used with state contract. The users in the DAG architecture may theoretically be in different states. After a long study, we decided to make some improvements to the DAG in CyberVein to make it more consistent with our needs.
In the IOTA or Byteball project, the project party emphasizes that the unit is not in sequence. Assuming user A transfers 100 units of Token to user B, and user B transfers 100Token to user C, the two transactions should be included in two units and broadcast separately to the network. If the transfer is only in view of the Token in terms of trade, order and no relationship, as long as to ensure the two units were received by other users,so the result of a different order and indifference. In view of the operation in terms of the data is not the same, however, changes in order for the same data will directly lead to
differences in the final result, so we introduced the contract unit is used to handle the situation.
In CyberVein, there are contract units besides normal trading units.
Unlike normal trading units, the contract unit introduces the concept of timestamps and direct parent’ s hash. The timestamp will record the unit’s broadcast time in UTC, making the operation of the smart contract a flow of operations.
A user may be due to network distance and against the same in different time period to receive smart contract the contract unit, and the timestamp can let the contract unit series, so as to ensure the consistency of the database results. The direct parent refers to the last contract unit of the current smart contract in the network with the premise of retaining the parent unit of the original unit, as shown in the figure below. (contract unit and normal unit). If a parent unit’s data forking occurs in a certain state, the user can decide to
merge and return the smart contract to a unified state.
Because of the new smart contract architecture of CyberVein based on DAG, the interaction between smart contracts becomes very simple. CyberVein users simply create another smart contract to perform other contract interactions.