A Distributed Energy Transaction Method Based on Blockchain

. Aiming at the multi-agent,multi-mode and multi-rule characteristics of the distributed energy trading market,a distributed energy trading method based on blockchain is proposed.In view of the randomness and volatility of distributed energy,the use of the decentralized characteristics of blockchain technology meets the needs of distributed energy market transactions;in order to improve the reliability of the distributed energy transaction process, it is proposed to use smart contracts to separate the transaction and the communication process between the blockchain and the energy fund account;with the help of Ethereum's "Raiden Network",this "off-chain transaction" method,frequent and efficient transactions are carried out,realizing the "tripartite" of distributed energy producers, grid institutions and users "win-win" to promote the opening and healthy development of the distributed energy market.


Introduction
The world has reached a consensus to vigorously develop renewable energy.However,the grid connection of renewable energy is volatile,intermittent and unpredictable. [1]At present,most distributed energy producers need to resell to users through grid institutions, which to some extent dampens the enthusiasm of electricity market participants for transactions.Therefore, the market needs a platform that allows buyers and sellers to communicate directly.The price of electric energy can be negotiated and discussed by both buyers and sellers. At the same time,there are certain ways for grid organizations to earn their own operating costs and additional income to achieve a win-win situation for the three parties. [2] Distributed energy transactions in the traditional power market have some common problem: ① centralized operation and maintenance, high costs of data storage and transaction;②system privacy data is easy to be illegally obtained and maliciously tampered with,and the security is poor;③there are many participants in energy interaction,the benefit distribution mechanism is not transparent and can not achieve a win-win situation for many parties.Therefore,a flexible trading model is needed to maintain the real-time balance of supply and demand. [3][4][5] This article analyzes the adaptability of blockchain technology in distributed energy applications,and proposes a distributed energy transaction system architecture based on blockchain and an "off-chain transaction" mode and transaction process based on the Raiden Tetwork.And the effectiveness of the method is verified through examples.

Matching features
Distributed energy has the characteristics of randomness and volatility.During the development of energy trading, its control structure has gradually developed from a centralized control type to a completely decentralized type,and market transaction entities,trading rules and modes have shown diversified and complicated characteristics.
As an emerging distributed infrastructure,blockchain has the characteristics of decentralization,openness, transparency,non-tampering,and traceability.Its core feature is decentralization,which can ensure that the status of each participating node in the network is the same to complete computing tasks together through a consensus algorithm. [6][7][8][9][10][11][12][13]

Market transactions
All nodes in the network jointly participate in the recording of transactions,and the decentralized transaction organization reduces transaction costs;at the same time,as a decentralized distributed ledger,the blockchain stores all the information in the system and all transactions.Records cannot be tampered with privately, and can be traced,ensuring the safety and reliability of transaction data.In addition,the block chain provides fair information reading permissions for many nodes,and can read and write block information at any time.The power grid and users can grasp the changes of schedulable resources during the transaction in time,which is convenient for adjusting the transaction strategy.
Buyers and sellers of electricity transactions can negotiate various aspects according to their own needs.They can conduct reliable transactions in a trustless state,and at the same time can eliminate the intermediary identity of the grid organization.In addition,in the blockchain mode,the grid organization transforms itself into the identity of the service provider of the entire distributed energy blockchain network for its own benefit. The grid organization needs to conduct security audits on each transaction to ensure the safety of its own grid.At the same time,the grid organization,with the most nodes and the largest amount of calculation,has a natural mining priority.So the grid organization can earn profits as a miner,and the grid organization itself can also act as a producer to sell electric energy.Under this new model, buyers,sellers and power grid agencies have reached a win-win situation,and cleverly solved the problems of distributed energy in power system transactions.

Blockchain-based distributed energy trading system architecture
This paper proposes a distributed energy trading system architecture based on blockchain and uses smart contracts to supervise transactions autonomously.The system is composed of transaction layer,extension layer and blockchain layer.Blockchain is the foundation of the architecture.At the same time,the transaction layer completes the energy exchange among multi-node users with the technical support of the expansion layer. Through blockchain and smart contract technology,the entire network can independently trade,maintain and manage transaction funds.The distributed energy transaction structure based on blockchain technology is shown in Figure 1.
The transaction layer includes distributed energy producers,grid companies,and users.Each entity initiates an energy transaction at this layer,implements a predeployed smart contract to form a transaction request, and sends the information of both parties of the transaction to the expansion layer for feasibility review. When the review is passed,a feasible transaction is formed,and the relevant data is finally stored in the blockchain layer.
In the extended layer,the central management agency is only responsible for services and has no actual power. The users of both parties of the transaction have reached a preliminary agreement on the transaction through negotiation,and the smart contract will be formed after safe and feasible review.At the same time,energy is the lifeblood of the country,and there must be certain restrictions in trading process.For example,the transmission of electric energy will have a certain impact on the power grid itself.Therefore,for the operation of the power grid,it is necessary to have a central organization to conduct security audits on all transactions.At present, the central institution that has the most control over the energy system is the central institution of the existing system.As the institution which is the most familiar with the safe operation of the system,it can be considered more comprehensively when formulating trading rules. From this point of view,energy trading does require a certain degree of management.
The smart contract should have attributes such as both parties to the transaction,energy quota,price,transaction time,and default amount.For the convenience of transactions,various energy sources are converted into electrical energy transactions in a unified manner.The contract is deployed and managed by the grid blockchain service agency.
The blockchain layer is the basic technology of the entire transaction structure.This layer consists of the P2P propagation network and the blockchain data storage part. The blockchain layer contains all the network nodes of the system.Each node can use its own storage device to store blockchain information.Each node has the same state and status.They communicate and interact with each other in a flat topology to form a P2P network. Each node is responsible for network routing,verifying and disseminating block data,storing data records, discovering new nodes, and nodes can decide to join or exit the network according to their own conditions.

The technical principle of Raiden Network's "off-chain transaction"
The article uses Ethereum's "Raiden Network" as an "off-chain transaction" method.By building a payment channel under the chain, both parties in the transaction freeze a certain amount of funds into the channel.As long as the channel exists,frequent and efficient transactions can be carried out.Raiden Network is a community solution for expansion under the Ethereum chain,using "recoverable sequence maturity contract" and "smart condition" to realize smart transfers. As long as both parties of the transaction have a transaction channel under the chain,they can perform high-frequency,two-way confirmation transactions under the chain based on the locked balance.The payment path under multiple channels constitutes the Raiden network.Proof of balance ensures that the transfer of funds between both parties can be achieved.When the channel is closed,the smart contract will broadcast the final transaction result to the blockchain and record it in the block.It not only solves the problem of transaction speed, but also saves block space.

Transaction process based on Raiden Network
With the help of the Raiden network introduced above, the distributed energy chain transaction method is realized.The blockchain transaction network is built through the Ethereum platform,and the Raiden network is used to achieve expansion,thereby achieving a greatly improved distributed energy trading scheme considering of weak centralization, trustlessness,privacy,security and transaction speed.A payment channel of the Raiden Network is constructed between users and distributed energy producers through smart contracts.Both parties deposit certain funds on the channel to form a balance certificate,and only both parties to the transaction can access the funds in the payment channel.The transaction process based on Raiden Network is shown in Figure 2.
A) Information release Each energy node user sends sales information to the blockchain network through an information disclosure contract,including seller node information, price,energy type,etc.Each node in the blockchain can see the sales information of each seller on the unique timestamplinked ledger of the blockchain.
B)The buyer and the seller trade and create a contract Buyers select their favorite products from the sales information in the blockchain,and use the deployed transaction contract in the blockchain to trade.This article intends to trade in the form of an order.
(a)The buyer sends a transaction request to the seller; (b)the seller confirms whether it is sold or not; (c)confirming that the sales order is established, otherwise the order will not be established; (d)when the buyer and seller agree to the order,it will be reviewed by the energy management agency.
Smart contracts mainly play two roles here:(a) control the asset keys in the blockchain,provide the contract agreed between the user and the distributed energy producer and facilitate the execution of the contract between the two parties in the transaction;(b) construct a micro-payment channel in the Raiden Network,realize the transfer of funds outside the chain, that is,off-chain transactions,save the funds frozen by both parties of the transaction, allocate the funds when the micro-payment channel is closed,and broadcast the results to the chain at the same time.
C)Service agency review Considering the decentralization characteristic of blockchain,so we can redefine the function of the central organization as a service provider.The review rules are formulated based on various security parameters in reality and the blockchain smart contract independently uses the data collected by the central organization to conduct a feasibility review of an order.

D) Record transaction execution contract
When the review is passed,the blockchain executes the transaction and records the transaction information.

Results & Discussion
This part develops blockchain smart contracts based on the Ethereum platform, using solidity programming language to write and deploy smart contracts,storing them on the blockchain and analyzing the correctness, stability and efficiency of the blockchain system by publishing an electricity purchase and sale contract on the blockchain.
By running a smart contract instance of a power purchase and sale contract in a P2P network composed of 3000 nodes,it is verified that the success rate of this method is about 99.5% and the average confirmation time of each transaction is about 12 seconds.
The result of executing smart contracts in a P2P network consisting of 3000 nodes is shown in Table 1. Compared with the original bilateral contract,the proposed transaction method can create a separate energy unit token contract in the blockchain,and the contract directly reads and writes the energy account fund balance information of each node.It separates the transaction and the communication process between the blockchain and the energy fund account,and avoids The communication failure problem of blocking the transaction process.
In addition, the paper uses Ethereum's "Raiden Network" this "off-chain transaction" method.By building a payment channel under the chain,both parties in the transaction freeze a certain amount of funds into the channel.As long as the channel exists,frequent and efficient transactions can be carried out.

Conclusions
This article studies the application of blockchain technology in the field of distributed energy trading.With the help of the distributed energy transaction system architecture based on the blockchain and the "off-chain transaction" method of Ethereum's "Raiden Network", frequent and efficient transactions can be carried out through smart contract technology,which can realize the "three-party win-win" among the distributed energy producers,power grids and users.It can promote the opening of the distributed energy market and reduce transaction costs.
This article is a preliminary study of applying blockchain technology to the field of distributed energy transactions. Further study about the combination of the energy field and the blockchain field will be promoted to establish a more mature energy-blockchain transaction ecology.