## 3 Scheme Design
### Smart Contracts  
Smart contracts play the role of automatic execution, security, and traceability in decentralized identity in addition to providing strong support for the construction of a decentralized identity system. Users authenticate through the account furnished by the identity provider and invoke the smart contract to complete the logistical transaction. The ORDER contract is designed to implement the core business logic of order transactions, including functions such as initiating the transaction order and querying. The contract is shown in Figure 3.  
Figure 2: The transaction process of the one-time public key.  
The mappings are used to record the information related to order transactions and record the corresponding relationship between orders and indexes. The struct Order includes elements such as the sender, recipient, price, order status, and order index for querying. The associative array contains the order array and the index array.  
Algorithm 1 outlines the function for submitting an order, which verifies whether the sender has sufficient balance. It then creates a new order and adds the order to the index array. When submitting a new order, the recipient's address and order price must be entered. This function will add the new order to both the order array and the index array.  
```
address recipient, address sender, unit price, unit index 1.Require(msg.sender.balance>=price)
2.Orders[msg.sender]=Order
3.ordersByIndex[orders.length]
4.Msg.sender.transfer(price)
```  
**Algorithm 2** getOrderStatus() public view  
Algorithm 3 is user-invoked and outlines a function to query the list of orders. It creates an empty array for storing order information and adds the order information to this array. It then returns the array, which contains information about the order type, sender, and order price.  
Figure 3: ORDER contract.  
```
input:uint[] memory, address[] memory, uint[] memory 1.uint[] memory ordertypes = new uint[](orders.length);
2.address[] memory senders = new address[]();
3.uint[] memory prices = new uint[]();
```  
**Algorithm 3** getOrderList() public view returns  
Algorithm 4 defines a function to confirm receipt and checks whether the order sender's address is correct. The sender address, receiver address, and order price are input. After confirming receipt, the function updates the address and index.  
```
input: address sender, address recipient, uint price 1.require(orders[].recipient == recipient)
2.orders[sender].completed = true;
3.ordersByIndex[orders[].index].completed = true;
```  
**Algorithm 5** mit() public  
Algorithm 5 details the'mint' function, which takes as inputs the order address and a 'tokenURI' string. The address is designated for receiving funds and, within the function, a check is performed to ensure that the order address is not a zero address. The 'tokenURI' is utilized to identify a specific token, allowing it to be referenced within the contract for both processing and manipulation.  
```
input: address order, string tokenURI 1.uint256 newItemId = tokenIds.current();
2.mint(order, newItemId);
3.setTokenURI(newItemId, tokenURI);
4.tokenIds.increment();
5.return newItemId;
```  
**Algorithm 6** mit() public