5. Profile of Requirements/Use Case Analysis

1. Business Use Case

To start off and to get to know how the smart contract should work, we were visualizing everything in use case diagrams. We started with modelling a business use case in enterprise architect. You can see in the following picture what this is going to look like.

Figure 16 - Use Case Diagram

In our case we have five business actors where one is the load owner who wants to buy the energy, and four of them are energy providers (photovoltaics as PV, combined heat and power unit as CHP unit, Battery and Grid) who want to sell their energy. As stated, the business goal of the energy providers is to sell the energy whereas the business goal of the load owner is to buy the energy as cheap as possible. They all come together in the business use case which is in our case, the peer-2-peer contract, energy trading. In this example there will only be P2P-Trading between the load owner and the energy providing parties. To make the understanding easier, the trading between the providing actors is not enabled. The business use case is invoked by the high level use case: To close 15 min contracts every 24 hours. This means, that the load owner is buying the energy in 15 minute blocks throughout the whole day.

2. High Level Use Case

To get a better overview on the problem, we will have a more detailed view on the high level use case which is shown in the following picture.

Figure 17 - High Level Use Case

The high level use case is being invoked by two primary use cases. These two primary use cases are being connected by an Energy Management System (EMS). The left primary use case is being simulated by Matlab. It is simulating how the energy production of the different business actors are and to what price they are willing to sell the energy. This means, Matlab is sending the input to the smart contract on the side of the energy providers and we do not have any influence on this part. The right primary use case, which is connected to the leftside of the EMS is about how the smart contract will be concluded. Therefore the wallets of the different business actors are needed especially for the settlement of costs at the end of the smart contract.

3. Activity Diagram

The following activity diagram will show, how the smart contract will work and what the smart contracting is checking step for step.

Figure 18 - Activity Diagram (1/2)
Figure 19 - Activity Diagram (2/2)

As mentioned earlier, the data on the energy production and the prices are being generated by a Matlab simulation. Based on this data the energy provider with the lowest price and the load owner are matching and closing a smart contract with each other. After the matching provider is chosen, the smart contract will be activated. At first, the smart contract checks, if the load owner had sufficient funds to pay the energy. If the funds are not sufficient, then the load owners wallet will be charged with Ether. If there are sufficient funds, the next step will be checking if there are enough tokens. If not, then the participants will get a notification that the amount of tokens is getting low. The step following on this is the transaction. The load owner is receiving the right amount of energy and the energy providers will receive the money. This is being visualized with the step settlement of costs. With this step, the smart contract is being closed.

4. Sequence Diagram

The sequence diagram is showing on which actor is interacting with another actor and what the order of these steps is.

Figure 20 - Sequence Diagram

Therefore the load owner is sending information about the load he requires to the EMS. The EMS looks, what energy provider will be the cheapest and gets the production data of the unit. If the production or the provided load matches the required load, the EMS requests the load. The exchange of the load and the money is being made in the smart contract and is therefore saved in the blockchain.

This is how the Smart Contract in our example is working.