1. Introduction
With the promotion of technologies for distributed renewable energy (DRE) generators and demand response (DR) programs, the boundaries between generators and consumers are becoming blurred. Jeremy Rifkin presented the concept of energy interconnection, the cores of which are renewable distributed energy and energy internet that would enable access to distributed energy and fair trade [
1]. This concept would also enable more forms of demand-side energy resources, such as heat and gas, to participate in the market. Traditional electricity transactions will develop into integrated energy resource (IER) transactions, which makes the transactions more complicated and the management more difficult [
2]. The direction of energy delivery is vital to enhance efficiency and decrease energy consumption, such how to handle the first mile and last mile delivery logistics [
3]. Therefore, designing an efficient trading scheme is vital to facilitate the development of the energy internet. The management of transactions can be divided into two primary categories: centralized and decentralized [
4]. The centralized transactions may have such issues as high operating costs, excessive time consumption, and security problems. To arrange scheduling instructions, the trading center has to collect all information regarding the distributed energy, which will lead to personal privacy concerns [
5]. In addition, when the number of transaction users increase, the data information will increase geometrically, which will increase the difficulty of scheduling resources in real time. Therefore, several scholars have presented the idea of decentralizing the distributed energy transactions [
6].
The preconditions for the distributed energy trading were analyzed [
7], which included the real-time information exchange, the self-optimizing strategy selection, the automatic transaction settlement, and the trading platform decentralization for the local energy internet. In [
8], a fully decentralized microgrid platform, “Overgrid”, is presented in order to carry out peer-to-peer (P2P) transactions. An automated DR program is presented in [
9], which is not fully decentralized, since the transactions are considered at the level of energy aggregators, together with being not for each individual part. In both [
10,
11], the multiagent system is adopted to realize grid decentralization. Each of the energy consumption devices is controlled by the agent that may respond to the signals from the network. Also, in [
12], the action policy put forward by each agent (termed as “scheduler” in this paper) becomes more complex, meanwhile considering more traffic issues. The distributed optimization algorithms are also employed for the purpose of decentralizing the power grid dispatching, for instance [
13]. A decentralized price-based DR system is presented in [
14], wherein, the price signal is adjusted by the difference in the supply and demand, and the users can adjust their demands in accordance with the signal.
Thereafter, blockchain has been considered as one of the emerging technologies, which can be employed for developing a platform for the decentralized energy transactions [
15]. Considering the blockchain technology’s characteristics of being open, decentralized, transparent, and tamper-resistant, it has the potential to effectively improve the efficiency of transactions, in addition to ensuring transaction security [
7]. Study [
16] concentrates on security issues for energy interactions and information in electric vehicles cloud and edge computing, and [
17] proposes a framework based on hierarchy and distributed trust to maintain security and privacy. Solutions, methodologies and technical considerations for addressing issues of data protection, security and privacy are described in [
18]. Meanwhile, blockchain is conducive to effectively improve the efficiency of transactions. In comparison with other methods, the main benefits associated with the blockchain adoption for the decentralized energy trading are that a third-party intermediary (for instance, a distribution system operator) is not required for the management and security of the energy transactions; and different kinds of energies (electricity, heat, etc.) can be freely traded [
5], catering to the requirements of IER trading. Currently, blockchain technology has been thoroughly studied for its basic principles, characteristics, and applications in finance, energy and other fields [
19,
20,
21]. Some research works have been carried out addressing the technical details of blockchain in order to scale up both the volume and speed of transaction by adopting the research results of cloud storage [
22,
23]. The research dealing with the applications of blockchain technology in energy transactions can be divided into three categories. The first category is the feasibility analysis, concentrating on the application possibilities and its capability with the trading mechanisms, for instance, renewable energy transactions, ancillary services, and large consumer’s direct power trading [
24,
25,
26]. The second category involves the research on the transaction process design and the smart contract design, for instance, automatic demand response, EV charging, and DRE’s P2P transactions in the distribution network [
27,
28,
29,
30,
31]. The third category deals with analysing the effect on the retail electricity market if the blockchain is widely utilized in the distributed power transactions [
32]. However, the current trading mode lacks consideration for the multiple energy types as well as multilateral trading parties in local IER transactions.
This study applied blockchain to the transactions among local IER resources. The idea of blockchain-based decentralized trading was put forward for the realization of the coordinated allocation of local IER resources. Corresponding to the transaction principles, a blockchain-based integrated energy transaction mechanism is proposed, dividing the trading process into two stages: the call auction stage and the continues auction stage. We designed the smart contracts of the users’ energy demands, the trading matchmaking, and the trading settlement, which were deployed on a private chain on the Ethernet for the simulation of the transaction process. The results can promote the development of a blockchain-based IER trading protocol as well as the engineering application of IER transactions.
The organization of this paper is as follows.
Section 2 provides introduction to the blockchain technology and its applicability to the distributed energy transactions.
Section 3 puts forward the decentralized IER transaction mechanism.
Section 4 presents both the functions and elements of the smart contracts built and deployed on the Ethernet.
Section 5 presents a simple case study, aimed at validating the transaction mechanism proposed.
3. Transaction Framework of Distributed Integrated Energy Trading
In the distributed energy trading framework designed in this paper, we assumed that each user had a blockchain account with a pair of keys, i.e., a public key and a private key [
4], and that smart meters were available to upload power data to the network. An energy usage plan should be determined before the trading session. The participants in the distributed energy trading must authorize the exchange to transfer a set number of tokens from their blockchain accounts to multi-signature wallets. Inspired by the mechanism of the stock market exchange, the transaction process proposed in this paper is divided into two stages: the call auction stage and the continuous double auction stage. The schematic process is presented in
Figure 1. The energy buyer authorizes the exchange so that the software could transfer a set number of tokens from the blockchain account to multi-signature wallets (signed by both the buyer and the exchange). The order contracts which contain the buyers’ order information and the sellers’ information can be sent to the exchange with the digital signatures by using their private key. The exchange classifies the orders provided by the buyers and the sellers, followed by combining them into order books. The form of the order books requires conforming to two principles: the same kind of energy and the same delivery time, so that the two principles could enter the settlement within the same trading period
T. Thereafter, the transaction processing contract or the matchmaking trading contract will facilitate the transactions. Moreover, the settlement contract will be created and deployed to the main chain for the purpose of ensuring the assets’ safety for the traders. After reaching the transaction agreement, the smart meters’ data will be uploaded to the settlement smart contract automatically and the tokens will be transferred as well.
The parameters used in this section are given in abbreviations
Table 1.
3.1. Call Auction Stage
During the call auction stage, the seller and buyer will make disposable matchmaking transactions providing guiding prices for various types of energy at each period in a day. The matchmaking transaction may be used as a reference for the quoted price during the double auction stage. It should be noted that while there are many ways to hold a call auction, this paper uses only one of them.
Besides the proceeding transaction process, the process in call stage has its own features:
(1) In call stage, a demand order contract address is required for each buyer’s order; and the seller writes its supply and price floor during the trading period into its bid order. For presentation purpose, the superscript letter of parameters are omitted in the following.
(2) All the information is sent to the exchange, which is responsible for classifying the orders into groups based on the energy types and trading time. The orders in the same order-book will be sent to one transaction processing smart contract, and the contract calculates the maximum value of the price floors submitted by all sellers, followed by delivering the price signal to the demand order contract. Demand (obtained from the demand order contract) and supply are followed by adjusting the price signal in accordance with the Formulas (1)–(3).
(3) In each interaction, the demand order contract modifies the amount of demand in accordance with its utility function. In the meantime, the supply is calculated at the quoted price signal. The interactions end until Formula (4) is satisfied.
We use the power buyers as an example. The electricity users’ utility function [
38] and profit function are shown as Formulas (5) and (6). Meanwhile, there are constraints on the users’ purchase quantity, per Formula (7).
Based on the principle of profit maximization, the demand can be calculated according to Formula (8):
Therefore, according to price , corresponding is provided by electricity users. This process can be written as a contract, which is deployed on the side-chain managed by the exchange, and executed off the main chain.
(4) When Formula (4) is satisfied, pre-transaction orders are generated. The exchange adjusts the orders as per the amounts of another type of energy provided by the multi-energy sellers.
For instance, the sellers, capable of supplying two or more types of energy, require special handling. The pre-transaction orders should be adjusted in accordance with their operation mode. For instance, combined cooling, heating and power (CCHP) follows the supply formula presented hereunder:
The operation mode should be determined through the determination of either the power by heat or the heat by power. In case of determination of power by heat, the pending transaction will be based on the power. The heat energy supply is subsequently calculated in accordance with the power transaction volume. The exchange will replace the heat seller having the same amount, but at a higher price in the same period, and vice versa.
(5) The transaction processing smart contract creates objects for the settlement contracts based on the consensus of the transaction. Following the settlement, the transaction amount is calculated in accordance with the Formula (11), which is based on the seller’s smart meter’s data. The money
in the multi-signature wallet is subsequently transferred to the seller by the means of state channels:
3.2. Continuous Double Auction Stage
After the call auction, traders who do not have a deal and new traders can hold continuous double auctions. During the trading cycle, buyers and sellers can submit their quotations at any time. The buyers’ prices are ranked from high to low and the highest quotation is the optimal purchase price. The sellers’ prices are ranked from low to high and the lowest quotation is the optimal selling price. The buyer who has the highest quotation can match the seller who has the lowest quotation. When the optimal purchase price is higher than or equal to the optimal selling price (the price margin is less than or equal to zero), a deal can be made, as
Figure 2 shows. Actual price is the average price of the two quotations. If the prices are identical, the transactions are completed according to the quotations’ submission time. During the matchmaking process, the matchmaking smart contracts need to update the status of each quotation (withdrawal or addition) in real time.
During the auction, market participants can adjust their quotations based on market information for the next cycle of trading until the total amount of electricity is sold out or the trading time is cut off. After completing the matching transactions, the two sides create the settlement smart contract and transfer the tokens.
Unlike the centralized approach, in the continuous double auction stage, the individuals participating in energy trading are interested in maximizing its utility (energy to be requested) without concern for the interests of others. Every participant can submit bidding to the matching contract at each trading interval. In this paper, we assume all participants adopted the AA strategy [
39], which adjusts the price according to the marketing environment.
Before entering the market, each buyer and seller calculate an appraisal price according to the expected purchasing price, production cost, deal price from the centralized competitive bidding stage and trading willingness [
39]. Thus, the buyer’s quoted price
and the seller’s quoted price
are calculated according to Formulas (12) and (13), respectively:
In the first iteration of trading, the results of the call auction are used as the optimal purchase price and the optimal selling price. In the following transactions, if the sellers and the buyers have not completed a deal, the buyer and the seller can adjust the quotation according to the base price and the current optimal selling price.
4. Formulation of Smart Contracts
Off-chain interaction technology is still in the initial stage of development; even the most mature application, Lightning Network, which promises to ease network congestion by moving transactions off the main blockchain, while it has not been suitable for high value payment system in light of security, only realizes the micropayment function in the network. Therefore, we will only discuss the contract related to the transaction mechanism in this paper. This section will discuss the construction of smart contracts by using the transaction between the distributed generators and electricity users as an example.
The transaction process involves five smart contracts in chronological order, including the transaction processing in the call auction stage, the determination of each user’s demand, the adjustment of scheduled orders, the matchmaking in the continuous double auction stage and the transaction settlement.
4.1. The Transaction Processing Contract
The input of this contract is the supply amount during a certain period and the corresponding price floor submitted by the sellers. The smart contract will record all orders and calculate the total power supply at the power price obtained by the iterative double auction. The smart contract will subsequently adjust the price and send the new price to the address of the customer’s demand order contract. The outputs include new electricity price (being sent back to the user’s wallet when the iterative termination criteria are not satisfied) and the trading volume of each seller (output when the iterative termination criteria are satisfied).
When electricity supply equals the demand, the contract will check whether the heat orders have been processed. If so, the contract will do two jobs. One is to calculate the heat supply according to the quantity of electricity provided by the CCHP and then transmit the data to the adjustment contract of the scheduled heat sellers. The other is to adjust the scheduled sellers according to the power data from the adjustment contract of the scheduled heat sellers and replace the same amount of electricity bought from the generators with the highest price floor. The basic elements of the contract are provided in
Table 2.
4.2. Demand Order Contract of Electricity Buyers
The buyers should transfer a deposit to the multi-signature wallet’s address according to the local electricity retail price. This part of the work is done before the buyer joins the market (building a status channel or joining the side-chain managed by the exchange). The input of this contract is the energy type, energy amount, and delivery time of sellers and buyers. The output includes the buyer’s address, the seller’s address, the energy amount and the energy price.
The function of this contract is to calculate user demand according to the price provided by the transaction processing contract. The basic elements of the contract are shown in
Table 3.
4.3. The Matchmaking Trading Contract
The matchmaking trading contract checks the delivery time and the energy type of the sellers and the buyers and classifies buyers and sellers of the same delivery time according to bid price. The contract then matches the sellers and buyers by the transaction mechanism presented in
Section 3.2.
The basic elements of the contract are shown in
Table 4.
4.4. The Settlement Contract
By means of the settlement contract, the funds can be automatically transferred according to the pre-agreed terms and deal terms after the delivery time of the transaction. The basic elements of the contract are shown in
Table 5.
The energy amount supplied by the sellers is submitted by smart meters. The settlement rules should be clarified in the market access agreements signed before the smart contract is created. After the delivery period, the electric data will be transferred to the settlement contract. The contract will be executed and the tokens will be transferred from the multi-signature wallet to the multi-signature wallet of the seller and the exchange account.
5. Case Study
To verify the effectiveness of the transaction mechanism proposed in this paper, the smart contracts for the distributed transaction were released on the test network of the Ethernet for simulation. There were five electricity buyers, in addition to four generators, merely providing electricity and two CCHP in this test. One of the two CCHP works to determine power by heat operation mode (this CCHP joins in the heat transaction processing contact) and other works in the determination of the heat by power operation mode (this CCHP joins the electricity transaction processing contract). We employ the Remix platform to test the smart contracts.
5.1. Deploying the Demand Order Contract of Electricity Buyers
The demand order contract consists of a constructor, a power calculation function, a data transfer function, and auxiliary functions. Constructor function has the same name as the contract. With the aid of this function, the contract can be deployed preliminarily and the initial variable can be initialized. The inputs of constructor are the parameters of the electricity buyers’ demand strategies, which are shown in
Table 6. These buyers create the demand orders and send them to the exchange address. This paper places all user data into one contract for demonstration purposes.
We use Solidity programming language, which is a contract-oriented, high-level language designed to target the Ethereum Virtual Machine (EVM), to build the contracts. Considering that the Solidity does not support decimal numeric storage, in order to ensure the accuracy of the calculation results, the initial data are magnified. The values of the buyers’ parameters are magnified 100 times as the constructor input. The operating results of the contract are shown in
Figure 3, which indicate the state of execution of the contract, the address of the contract, the address of the executor, the gas value of the execution of the contract, the contract’s hash value, the log, and other information.
The demand order contract calculates the output based on the quoted price according to Formulas (9) and (10). As shown in
Figure 4, the outputs of four users from the initial quotation (11 Finney/MW, where Finney is the unit of virtual currency in Ethereum) are 920, 590, 960, 800 and 1460 kW.
The call function can transmit the output of each electricity buyer to the transaction processing contracts. In case of being successful, call function will return a Boolean parameter “true”. The process is presented in
Figure 5. An array of five integer variables, presenting the buyers’ electricity demand, was transmitted from the address of the demand order contract to the transaction processing contract.
5.2. Deploying the Transaction Processing Contract
The transaction processing contract can be deployed on the exchange’s wallet, to which the energy buyers transfer a margin prior to trading. This contract consists of a constructor, an input interface function, call functions, a price adjustment function, a supply amount calculation function, the other kind of energy’s amount calculation function, a seller readjustment function, and auxiliary functions.
The assumed seller’s parameters are presented in
Table 7. It requires observation that only the sellers, having the same delivery time, will be sent to the same contract.
The result of input interface is presented in
Figure 6. Furthermore, the initial quotation (11 Finney/MW) is transmitted to the buyers’ demand order contract, and the process is recorded in an event. By the call function, the integer data 1100 is transferred from the address of the transaction processing contract to the demand order contract, as presented in
Figure 7.
The output returned by the demand order contract is [92,59,96,80,146]. Thereafter the transaction processing contract adjusts the prices in accordance with the values for Formulas (1)–(3) and the updated price is 12.21 Finney/MW. The supply calculation function calculates the electricity provided during the iterations, which is 4500 kW. Also, if the supply is not equal to demand, then proceed to the next iteration.
Following three iterations, the buyers’ demands are 890, 550, 900, 760 and 1400 kW correspondingly, while the price is 12.24 Finney/MW. Subsequently, setting the balance indicator inside the contract to be “true” and checking the balance indicator of heat transaction processing contract. If the indicator is “true”, then this contract will get the electricity generated by the CCHP that is scheduled by the heat transaction processing contract and send the heat generated by the CCHP which is scheduled by this contract. The way to transfer data between contracts is same to the call function mentioned above.
The sellers’ scheduled energy amount is presented in
Table 8. Assuming the electricity amount received from the heat transaction processing contract is 400 kW, which is provided by the CCHP “0xdd870fa1b7c4700f2bd7f44238821c26f7392148”. The adjustment is recorded as an event, which is presented in
Figure 8. This figure suggests that the seller “0x14723a09acff6d2a60dcdf7aa4aff308fddc160c” reduces 400 kW.
5.3. Deploying the Matchmaking Trading Contract
This contract realizes the matchmaking of the sellers and the buyers in accordance with the method in the continuous double auction stage. This contract consists of a constructor, two input interface functions, a matchmaking function, a withdraw function and auxiliary functions.
The two input interface functions are used to receive the data from both the sellers and buyers, together with distributing them into order sets of different times and energy types. The interface function for the buyers is “payable” function, requiring the buyer to send its’ advance deposit. The bidding of buyers and sellers is presented in
Table 9. With regard to the demonstration purposes, they are assumed to bid for the same energy type and delivery time.
The matchmaking function finds the highest buyers’ bidding price and the lowest sellers’ bidding price, followed by comparing them and calculating the transaction price and amount. If the bidding is executed in all, the contract will set the state indicator of the buyer or the seller as “true” in order to exclude them from the order set. The transaction in the first round is recorded in the event, called “Transaction log”, as presented in
Figure 9. The Seller0 sells Buyer1 200 kW at 10.72 Finney/MW, and the state indicator of Seller0 is set to be “true”, implying that the Seller0’s energy has been sold out.
Other functions are common in the functional design of smart contracts. The heat bidding can be processed in the same manner.
Over the trading cycle, there are 5 transactions concluded in 2 rounds of trading, as presented in
Table 10.
5.4. Deploying the Transaction Settlement Contract
The transaction settlement contract primarily comprises the constructor, the funds transferring function, and auxiliary functions. This contract should be deployed on the main chain of Ethereum and the transfer of funds should be confirmed by the multiple signatures (the exchange and the buyer).
This paper takes the Seller0 and the Buyer1 in
Table 8 as an example for the illustration of the process of the transaction settlement when the energy has been delivered.
The input parameters of the contractor function include “0xb868ab9cf247345f586fa0f0750ce110c2202db3” (the address of the user), 200 kW (the target output), 10.72 Finney/MW (the transaction price).
Assuming that the actual output of the seller is 150 kW, which is insufficient, the seller faces a punishment that the contract is settled at 90% of the transaction price. The amount that the buyer requires paying to the seller is presented in
Figure 10. It records the transfer of tokens between the two addresses in the form of an event.
These contracts were deployed on Metamask, an application allowing the users to run Ethereum dApps in a browser. The event that records the transaction’s process is presented in
Figure 10. This figure reveals that 1.4472 Finney has been transferred from the address of the generator to the user.
5.5. Transaction Mechanism Comparision
The social welfare and market efficiency [
40] are chosen as the evaluation indicators in order to compare the mechanism put forward in this paper, the single call auction mechanism and the single continuous action mechanism. The social welfare of the proposed mechanism, the single call auction mechanism and the single continuous action mechanism is 130.88 Finney, 130.49 Finney and 121.72 Finney, correspondingly. Market efficiency is the ratio between actual social welfare and maximum social welfare 134.18 Finney (all transactions are dealt with at a time, which is unrealistic because of the renewable energy’s forecast errors and uncertainty of consumers’ behaviors), which are 97.25%, 97.54% and 90.71%, correspondingly.
In accordance with the principle of economics, when the market transaction price is equal to the equilibrium price, social welfare is the largest, which is the situation with maximum social welfare. In the single call auction mechanism situation, the market is cleared once in each trading cycle (for instance, once in an hour); if the seller’s or buyer’s delivery time is close to the bidding time, it would not have a second bidding chance. The transaction model put forward in this paper is a compromise of market efficiency and uncertainty characteristics of market participants (for instance, renewable energies and energy consumption behaviour), which achieve the best performance among the three practical mechanisms. The mechanism put forward in this paper is superior to the single call auction mechanism since the transactions made in call stage reach the beneficial maximum. In short, the transaction model has the potential to balance the market efficiency and the trading convenience.
6. Conclusions
The decentralized characteristic of blockchain technology is its high compatibility with the trading demand of integrated energy resources. This paper discussed the application of blockchain technology in the integrated energy trading and put forward a decentralized transaction scheme, including the interaction process of the smart contracts.
The transaction process put forward in this paper is divided into two stages: the call auction stage and the continuous double auction stage. Accordingly, the trading parties adjusted their bidding by monitoring the information broadcasted in the blockchain so that more freedom could be provided for them to participate in the market. The authors designed and deployed the trading smart contracts on the Ethereum website, in addition to verifying the trading process. In the study case, distributed generations and users can achieve transaction conclusion and transaction settlement without the participation of centralized institutions; besides, the characteristics of blockchain can guarantee the interests of the market participants. In comparison with the single type transaction model, the proposed mechanism finds a compromise between the market efficiency and the participants’ convenience. The proposed mechanism can meet the demand of the distributed, small-scale and low-cost transaction of the integrated energy resources in micro-grid, and can be extended to the transactions for the other production forms, such as energy efficiency in supply chain and transportation solutions.
Further studies will focus on two major parts: firstly, setting up a platform to put the distributed transaction mechanism into practice, and evaluating its effectiveness and practicability. Secondly, designing the blockchain-based transaction mechanism among the virtual power plants and the distributed resources.