# Design of Multi-Chain Traceability Model for Pepper Products Based on Traceability Code
## 4 Construction of Multi-Chain Traceability Model for Pepper Products
### Storage Schema Design for Multi-Chain Traceability Model  
The mapping relationship reflects the one-to-many relationship between the product traceability code and the transaction address. The traceability is only indexed according to the mapping relationship, so the query speed is much faster. The product traceability code and transaction address are recorded by the root node, and the leaf nodes are addressed by the transaction address, which is unique on the side chain to avoid tampering with the data. The mapping relationship and key are stored on the main chain; when a transaction is passed on the side chain, the main chain first checks whether there is already a map for this traceability code. If there is no record on the main chain, the mapping relationship of the traceability code is created, which establishes a mapping relationship between the traceability code in the main chain in the form of an object and the address of the transaction in the side chain, and if the mapping relationship already exists in the main chain, the mapping relationship is updated. The main chain and side chains correspond  
Figure 1: Multi-chain traceability model for pepper products. to one-to-many relationship, in which one main chain corresponds to several side chains. The transaction addresses in the side chains are unique, which prevents the data from being tampered with during the storage process. The schematic diagram of the mapping relationship is shown in Figure 2.  
The final traceability code of the product is written into the blockchain to form a mapping relationship with the transaction address of the side chain storing the traceability information, and the traceability code is used as an index and unique identification. A mapping relationship is established between the transaction address of each link when it is uplinked into the side chain and stored in the main chain, and the block body uses key-value pairs to store the relevant information. A side chain is created for each of these nodes: planting, processing, storage, logistics and sales. The traceability information of each link is stored in the side chain of each node of the supply chain and returns the transaction address of its exchange in the transaction address of each link traceability code. The transaction address in the format of key-value pairs is stored in the main chain, and if it is necessary to update the information of peppercorn products, it is necessary to write the transaction address of the traceability information into the corresponding structure to update its transaction address. The consumer can enter the traceability code of the liquid product, exchange codes by entering the traceability code in order to obtain the traceability code of each link, obtain the transaction address, and query the traceability information on the corresponding blockchain with the transaction address. When uploading, the vendors of each link can upload the data into the side chain respectively and store the transaction address of the side chain and the link traceability code of each link through the main chain. When querying, the transaction address of the pepper product in each side chain is queried in the main chain through the link traceability code, and then the traceability data of each link is queried in the side chain through the transaction address, and the querying of each side chain can be carried out synchronously. First of all, the traceability data should be uplinked, and the data of different traceability links should be uplinked by generating smart contracts for the corresponding channels. After the uplinking of each link, the main chain is updated through the exchange node, and when the data of other traceability links are uplinked, the key-value pairs of the main chain object data are updated by finding the corresponding traceability data objects through the batch number. Taking the uplinking process of planting side chain as an example, each stage is described in detail as follows:  
Figure 2: Mapping relationship diagram.