# Proof of Flow: A Design Pattern for the Green Energy Market
## 4 Proof of Flow Design Pattern  
To provide a clear and unified framework that defines the roles, responsibilities, and interactions between DERs and Aggregators, we propose the Proof of Flow design pattern. We assume that DERs only operate as energy producers, i.e., they inject energy into the power grid. Furthermore, the Aggregator acts on behalf of the Operator, which is responsible for coordinating the overall energy grid. Proof of Flow design pattern aims at providing efficient and seamless coordination between the entities involved, enabling effective integration of DERs into the grid, and solving potential disputes. We describe the pattern according to the typical sections found in the GoF book [38]. **Name**  
Proof of Flow. **Intent**  
Assist the actors responsible for the energy production and transmission to interact with each other and trace data to reward producers and solve potential disagreements on the amount of energy produced. **Motivation**  
Consider an Aggregator orchestrating DERs aiming at providing electrical energy to the system in a localized, small-scale setting. DERs use local smart meters to measure and locally store the energy production data which, typically, are sent to the Aggregator. This acknowledges the offers of energy from selected DERs whose production goes into the distribution network. Data consisting of measured energy produced and delivered, as well as commands and agreements between several parties are crucial for all the actors to work together. If such data and messages are exchanged over the cloud, a trusted authority is needed to hold them, and ensure their veracity. However, when none of the involved entities are an undoubted authority, then it is difficult to make one emerge as trusted. By leveraging blockchain technology, it is possible to forgo the cloud-based trusted authority while assuring transparency, immutability, and decentralization in the exchange process. Blockchain technology offers the possibility to record data in a permanent storage, in such a way that they cannot be modified, deleted or disputed. Blockchain nodes, running smart contracts and storing data, consume gas for such operations. The consumed gas is an operating cost, equivalent to real currency, that need to be paid. Such a cost has to be minimised for making the solution based on blockchain sustainable. Moreover, the blockchain nodes cannot determine by themselves whether received data are accurate, hence a mechanism is needed to solve potential disagreements on the truthfulness of data. **Applicability**  
Use the Proof of Flow pattern to replace reliance on a trusted authority holding data in the cloud by recurring to blockchain technology, in a cost-effective and efficient manner, and when the need to solve disputes could arise. **Structure**  
Figure 2 shows the structure of the Proof of Flow design pattern, the energy players, the proposed smart contracts, and all the interactions among them. The DER that is depicted has an energy meter (DM1) physically linked, by a power line, to an energy meter of the Aggregator (AM1). The latter, in turn, has multiple energy meters, each associated to the power lines connecting to other DERs. There are several interactions with and between smart contracts, according to the wallet address invoking a function of the smart contract. e.g., ARIA, as can be seen, only accepts deposits, which it routes to Vault, and does not allow withdrawals. Instead, it forwards withdrawal requests to Vault, which will approve or deny them according to the available unlocked balance associated with the specified wallet address. **Participants**  
The participants of the Proof of Flow design pattern are the following. * ARIA (Aggregator Renewable Integration Agreement) smart contract, holding a list of active and prospective DERs, keeps energy balances for DERs and triggers payments to DERs that have provided energy and to the Aggregator, for its role in governing them.