**4. Distributed energy markets**

One of the most promising ways to use the blockchain in the energy sector is the information support of the energy market in connection with the above-mentioned trend towards its decentralization. Flexible spatial distribution of generation and consumption of energy resources improves the quality of customer service, reduces operating costs and ensures reliable network operation. Given the growing demand for renewable energy and tightening control of carbon dioxide emissions, the production of electricity on microgrids with blockchain information support is becoming increasingly important in the development of the energy sector [20].

In the operation of a microgrid blockchain, it is especially important to provide an appropriate transaction mechanism and implement optimization of a microgrid power output. In order to achieve the lowest total cost of a microgrid blockchain, a two-way transaction mechanism and corresponding smart contracts are usually used.

There is no perfect centralized transaction information support model that would provide complete trust in terms of ensuring the interests of all parties. Blockchain technology largely combines the properties of reliability, transparency and security. Distributed decentralization helps organize low-cost and highly efficient power distribution work, solving problems of trust and energy efficiency [21, 22].

The microgrid blockchain can increase or decrease the contribution of a node according to real needs, which is carried out using a transaction mechanism and ensures energy optimization. Such a flexible mechanism is especially important for "renewable energy sources" such as photovoltaic, wind, tidal, etc. Renewable energy sources are unstable and cannot work effectively in isolation. For them, the stabilizing function of the blockchain is critical.

Let us consider the transactional architecture of the microgrid blockchain and propose one of its possible efficient architectures. The general structure of the energy blockchain consists of many microgrids and several large power grids connected on a point-to-point basis (P2P). Each node of the blockchain network can turn on and trade through the network. Each microgrid corresponds to one specific type of energy device: a photovoltaic array, a wind turbine, and so on. The microgrid also includes energy storage equipment (batteries). When energy generation is insufficient, batteries give out energy, and when generation is excessive, it is stored. The users of the microgrid blockchain are consumers of household energy and owners of electric vehicles.

In the blockchain, the distribution of energy among the numerous microgrid users is controlled by a special control block. The structure of energy transactions represents a "microgrid – user" relationship, i.e. both parties trade according to a one-to-many structure. However, since the generation of renewable energy is largely influenced by natural conditions, and consumer behavior is relatively stable, then

there is often a mismatch between electricity generation and demand in the trading link of the microgrid. When electricity production exceeds demand, the excess capacity must be sold to the outside world; when there is not enough electricity to meet the demand in the microgrid, electricity must be purchased from the outside. If this kind of relations will be carried out only with large power networks, this will increase unnecessary costs due to fixed prices at "wholesalers" and creates need to perform electricity transactions arrhythmically.

Unlike the structure of blockchain transactions with a single microgrid, in a multicomponent blockchain, each microgrid is located in parallel, independently of each other. On the electricity trading market, formed on the basis of multi-grid blockchain, the parties to each transaction are equivalent, regardless of belonging to a microgrid. In this case, the mechanism of "bilateral auctions" is being implemented, which ensures a high degree of market adaptation to changing economic and natural conditions. Bilateral smart contracts do not require participation of third-party institutions; direct transactions are not only simplified, but they also provide a greater level of confidentiality and independence. The chain data structure makes the data immutable and easy to check, and makes it easier to monitor the market.

Designing a blockchain structure of the market, after defining the overall architecture, implies the ability to model and optimize the power of the microgrid blockchain. Two aspects are taken into account: power generation periods and energy storage schedules.

The main generating devices of the regional energy system are photovoltaic panels (pv) and wind turbines (wt). Conventional fuel generators are used as emergency power generation equipment. The electrical energy exchanged between microgrids comes from electrical reserves, so it is not within the scope of the general model. An energy storage equipment mainly consists of lead-acid batteries.

The microgrid calculates its own cost of electricity generation and the cost of transactions with large power systems. On the basis of the calculations, an objective function is built to optimize the sale or purchase of capacities through the macrogrid blockchain.

The process of trading energy between microgrids under the blockchain is divided into separate stages. The selling price of electricity in a large grid does not change with time, but the price of electricity in transactions between microgrids changes over time. Transaction participants naturally prefer to trade with microgrids with lower rates. To achieve more efficient electricity trading, it is necessary to develop a dynamic method of managing the blockchain as a whole, which this technology allows to do very efficiently.

The mechanism of bilateral auctions should provide flexible allocation of resources, ensure the coordinated and orderly conduct of multilateral transactions, and is widely used in multilateral trading platforms. The bilateral auction mechanism has basically two forms: direct bilateral auction and centralized bidding. Centralized trading should focus on the quotes of all trading participants for a certain period of time, and after several operations, reload the information. This transaction model requires the execution of transactions within a fixed time, while it requires a relatively large amount of calculations that require the involvement of significant computing power.

The direct two-way auction mechanism is more suitable for transactions between microgrids. The process of two-sided auctions is oriented towards the starting price and sale price models. The main control center of the blockchain balances supply and

### *Perspective Chapter: Blockchain Technology in the Field of Energetics – Organization of Effective... DOI: http://dx.doi.org/10.5772/intechopen.111445*

demand. When the total amount of electricity, offered on the market, is lower than the demand for it, the selling price will be increased accordingly, and vice versa.

When trading between blockchain microgrids takes place, no third-party institution is expected to be involved as a transaction coordinator. Instead, a smart contract technology is proposed, basing on the use of a special computer program that runs on the blockchain. The algorithmization of the bilateral auctions and the smart contracts allows to ensure following the business logic and to eliminate the risk of interference by third-party attackers. It provides trust between the parties of the transaction by logging the actions: all key information about the transaction is recorded into the blockchain for its further confirmation. Based on the price forming model, a proper form of the transaction is developed, and a smart contract is drawn up.

The contract design involves segmenting the lifecycle of the blockchain microgrid for 24 periods (hours) per day and calculating supply / demand in each period. All surplus will be distributed among the microgrids according to their needs, and corresponding smart contracts will be formed. The participants, whose requests were not satisfied, will receive energy from one of the major power grids at a fixed price.

The preparation and implementation of the smart contracts consists of several stages, such as registering requests, publishing offers, buying and selling, checking results, and settling transactions. Registration of requests and publication of offers are used for formation of quotations. The functional implementation of the purchase and sale is the mechanism of bilateral auctions, which has been described above. The function of checking results involves using digital signatures and recording information about the transaction in the blockchain. The transaction settlement function tracks the transmission of electricity and its payment, after which the smart contract is deactivated.

Development of the architecture of the decentralized and intelligent technology of blockchain transactions increases the efficiency of using the microgrid power and ensures the openness, transparency and security of transactions. Future development in this area should mainly focus on blockchain sharding technology and improvement of the speed and efficiency of blockchain algorithms, minimizing the imbalance between electricity supply and demand.
