Decentralized electric energy transaction method and system based on block chain, and storage medium

Through blockchain technology and smart contracts, decentralized electric energy transactions are realized, solving data security and privacy issues in centralized transactions, reducing transaction costs, and increasing the benefits of market participants.

CN118569986APending Publication Date: 2024-08-30STATE GRID JIANGSU ELECTRIC POWER CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410444677.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-15
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

In a centralized power trading system, consumer data security and privacy are difficult to guarantee, and transactions controlled by central entities increase costs, resulting in higher utility costs for consumers and less benefits for prosumers. A decentralized system is needed. Mechanism to achieve secure and economical end-to-end energy trading.

Method used

Use blockchain technology to design a decentralized electricity trading method based on blockchain, realize direct energy transactions between market participants through smart contracts, and use the Solidity platform on REMIX IDE to design main smart contracts, end-to-end smart contracts and P2G smart contracts conduct energy transactions based on the minimum electrical distance strategy to ensure the security and economy of transactions.

Benefits of technology

It achieves transparent, secure and economical energy transactions between market participants without relying on additional entities, maximizing the profits of prosumers, while reducing consumer spending and transaction costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118569986A
    Figure CN118569986A
Patent Text Reader

Abstract

The invention discloses a decentralized electric energy transaction method and system based on a block chain, and a storage medium, and relates to the technical field of distributed transaction, and the method comprises the steps: preferentially considering an end-to-end electric energy transaction market between nodes with the nearest electrical distance, calculating the electrical distance according to a topological structure and node positions in a network, sorting the diasters according to the minimum electrical distance; creating a user data block with a unique identity hash, and sending the user data block to the smart contract to meet a pre-formulated rule; the smart contract comprises a main smart contract, an end-to-end smart contract and a P2G smart contract; the main smart contract verifies market participation of each node through an end-to-end smart contract until the market is cleared; and after the market is cleared, the main smart contract and the P2G smart contract coordinate to clear the market. Compared with the prior art, the energy transaction method has the advantages that the energy cost of the consumer is reduced, and the profit of the consumer is increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of distributed transaction technology, and specifically to a decentralized electric energy transaction method, system and storage medium based on blockchain. Background Art

[0002] In recent years, the global demand for electricity has grown rapidly, causing the share of electricity in total energy consumption to continue to rise. This increase in electricity demand will require investment in new generation capacity, thereby increasing the cost of power generation. Smart Grids (SGs) are an advanced form of traditional power grids that can achieve effective energy management by allowing interaction between energy producers and consumers. This can reduce dependence on new generation investment and encourage the efficient use of existing generation capacity.

[0003] SG facilitates seamless control of power generation and energy distribution, thereby promoting the entry of new players in the electricity market. Environmental concerns and the decline in the cost of renewable energy have driven the integration of distributed energy resources (DERs) based on renewable energy (RE). The development of sensor design and new communication protocols has paved the way for peer-to-peer energy trading mechanisms. These mechanisms enable electricity consumers who have installed DER to trade their excess generation in the market and act as prosumers. The volatility and intermittency of DER-based power generation requires energy users to be connected to the grid to maintain reliability.

[0004] End-to-end energy markets can be operated centrally. However, in centralized trading systems, data security and privacy of consumers are always a concern. In addition, energy transactions between different peers are controlled by a central entity responsible for market management. This manifests itself in additional costs for peers due to the participation of an additional entity, resulting in higher utility costs for consumers and less benefits for prosumers. This requires a shift from a centralized system to a decentralized mechanism. Decentralized end-to-end transactions provide direct interactions between nodes and incentivize small-scale energy prosumers to trade their excess generation. This enables participants in local energy markets to benefit more from transactions over centralized mechanisms. Therefore, a mechanism needs to be designed to ensure the safe operation of decentralized end-to-end transactions in local electricity markets.

[0005] Blockchain is an effective technology for reliable and secure decentralized end-to-end energy trading. The technology is user-friendly and has broad application prospects. In addition, the technology enables transparent communication between local market participants to facilitate optimal decision-making. The basic feature of blockchain is to monitor all changes without changing any blocks, thereby ensuring seamless cash transactions, agreements and property. In addition, the information stored in the blockchain cannot be changed. The application of blockchain in load balancing, power grid operation, different bidding strategies and other fields is being widely explored.

[0006] However, the implementation of smart contracts using blockchain mechanisms in decentralized peer-to-peer markets remains to be explored. Summary of the invention

[0007] To address the deficiencies mentioned in the above background technology, the purpose of the present invention is to provide a decentralized electric energy trading method and storage medium based on blockchain. A hybrid end-to-end energy trading market is realized through a decentralized mechanism based on blockchain. It allows market participants to directly trade energy without involving additional entities. In the blockchain-based energy trading mechanism, contracts play a vital role. Therefore, smart contracts are designed for the effective implementation of this trading mechanism. These contracts are designed using the Solidity platform on REMIX IDE. Producers and consumers interact with each other through the main smart contract to perform end-to-end energy transactions until the market is cleared. Then, they interact with the grid through the Peer-to-Grid (P2G) smart contract to sell / purchase additional energy. The results show that the proposed method can realize an intelligent, safe and economical energy trading mechanism.

[0008] The first aspect of the present invention relates to a decentralized electric energy trading method based on blockchain, comprising the following steps:

[0009] Prioritize the end-to-end power trading market between nodes with the closest electrical distance, calculate the electrical distance according to the topological structure and node location in the network, and sort the prosumers according to the minimum electrical distance;

[0010] Creating a block of user data with a unique identity hash, which is sent to a smart contract to satisfy pre-established rules;

[0011] The smart contracts include a main smart contract, an end-to-end smart contract and a P2G smart contract; the main smart contract verifies the market participation of each node through the end-to-end smart contract until the market is cleared; due to the reduction in power loss, the minimum electrical distance strategy is used as the basis for the interaction of each peer in the energy trading mechanism; after the market is cleared, the main smart contract coordinates with the P2G smart contract to clear the market.

[0012] Optionally, the end-to-end power trading market between nodes with shorter electrical distances is given priority, the electrical distance is calculated according to the topological structure and node position in the network, and the producers and consumers are sorted according to the minimum electrical distance as shown in the following formula:

[0013] Elec_Dist ij =Z ii +Z jj -2Z ij

[0014] Among them, Elec_Dist ij is the electrical distance between nodes i and j, Z represents the Z-node matrix;

[0015] After the market is cleared, the P2G smart contract is executed;

[0016] Main smart contract updates prosumer costs and consumer costs

[0017]

[0018]

[0019] Where: P t G2P Supply electricity to the grid to prosumers, is the grid price, is the market price of the same industry, P t P2G For prosumers to sell electricity to the grid, P t cons / pros It is for producers and consumers to sell or purchase electricity from their peers.

[0020] Optionally, after the user data block is created, the main smart contract verifies the user data block and adds it to the blockchain;

[0021] Participants interact with the peer-to-peer smart contract until the market clearing time and then with the P2G smart contract; since consumers and prosumers can interact with peers as well as the grid, the proposed system evolves into a hybrid energy market.

[0022] The first step in formula derivation is the design and verification of data blocks. In the electricity trading market, smart meters are used to collect various electrical values ​​to create these data blocks.

[0023] Optionally, the user data block includes:

[0024] The buyer's data block includes the node number, security key, category type, timestamp, and power requirement; the security key is a unique hash value, the category represents the alert or measurement of the data, the power requirement is the power required by the buyer, the timestamp is the exact moment when the block was added, and the cost represents the energy cost of the main smart contract update;

[0025] The seller data block includes power availability information, information similar to the buyer data block, excess power available for sale, the price of the sold power and the profit earned by the seller updated by the main smart contract; for the seller data block and buyer data block fields, the values ​​of the available power and its price for seller interaction in the end-to-end energy trading market are defined.

[0026] Optionally, the workflow of the master smart contract, involving the interaction between the buyer and the seller and the data verification on the blockchain, includes the following steps:

[0027] 1) At the beginning, the system receives a request and determines which user initiated the request;

[0028] 2) If the user is a buyer, the system will ask for the buyer’s data and perform block verification on the buyer’s data;

[0029] 3) If the user is a seller, the system will ask for the seller’s data and perform block verification on the seller’s data;

[0030] 4) Block verification buyer / seller: Verify the data of the buyer and seller respectively. If the category of the data is "measurement", set 'verifiednode' to true, otherwise set it to false;

[0031] 5) Start end-to-end interaction, which refers to direct interaction or communication between buyers and sellers;

[0032] 6) Check market settlement time: The system will check whether the market settlement time has passed;

[0033] 7) If the market settlement time has ended, the system will further check the energy situation;

[0034] 8) Energy detection: Perform P2G operations to process energy shortage and energy surplus;

[0035] 9) Ending condition: The ending condition is the result of checking the market settlement time and energy situation.

[0036] Optionally, the working process of the end-to-end smart contract involves the electric energy transaction between the buyer and the seller, including the following steps:

[0037] 1) Input buyer user i: the system receives the buyer’s information;

[0038] 2) Loop over j: Loop through potential sellers j;

[0039] 3) Calculate the electrical energy distance between buyer i and seller j;

[0040] 4) End the loop: complete the distance calculation for all potential sellers;

[0041] 5) Calculate the minimum energy distance: determine the seller closest to the buyer among all sellers, that is, the minimum energy distance;

[0042] 6) Record the bids between buyer i and seller j: The system records the bids between the buyer and the most recent seller;

[0043] 7) Check whether the seller’s electricity is large enough to meet the buyer’s needs;

[0044] 8) If the seller has enough electricity, the system will reduce the seller's electricity and calculate the buyer's fee, while increasing the seller's profit;

[0045] 9) If the seller has enough power, the buyer's power will be reset to zero, indicating that the transaction is complete;

[0046] 10) If the seller’s electricity is not enough to meet the buyer’s demand, the system will calculate the fee based on the amount of electricity purchased by the buyer and update the seller’s profit;

[0047] 11) Ending conditions: After the transaction is completed, the system will end this process.

[0048] Optionally, the workflow of the P2G smart contract involves a process of handling an imbalance in energy supply and demand, comprising the following steps:

[0049] 1) When the system detects insufficient energy supply, it performs the following operations;

[0050] 2) Buyers calculate the fee based on the grid electricity price and the amount of electricity purchased;

[0051] 3) Due to insufficient energy supply, the buyer’s power is set to zero, indicating that the transaction cannot be completed;

[0052] 4) When the system detects that the energy supply is sufficient, it performs the following operations;

[0053] 5) The seller calculates the profit based on the grid electricity price and the amount of electricity sold;

[0054] 6) Due to the excess energy, the seller’s electricity is set to zero, indicating that all the remaining electricity has been sold.

[0055] Optionally, the steps of interaction between the peer and the smart contract are as follows:

[0056] 1) Market participants buyers / sellers interact with the master smart contract to participate in electricity trading; a separate data block is created for each participant;

[0057] 2) After the block is created, the main smart contract verifies each participant by checking their unique identity hash and category; once the user is verified, the main smart contract checks the status of the end-to-end smart contracts;

[0058] 3) Before the market clears, the master smart contract forwards the request and information of energy buying or selling to the end-to-end smart contract; if the request comes after that, the master contract rejects the request;

[0059] 4) During the end-to-end smart contract processing before the market clears, all possible node matching combinations are selected, and the match with the smallest electrical distance is selected; this process is repeated until the market clears;

[0060] 5) After the market is cleared, the power consumption and bills of each user are updated; the remaining power information related to the power demand of the prosumer and consumer is sent to the P2G smart contract;

[0061] 6) P2G informs buyers of the current grid price and sellers of the current grid price, which can be purchased by the utility grid; in this way, electricity demand is met by purchasing excess generation from prosumers through P2G interaction;

[0062] 7) Consumers pay the cost of energy use, while prosumers receive credits by selling their excess generation to peers and the utility grid;

[0063] 8) Market participants continue to participate in transactions through these smart contracts.

[0064] The second aspect of the present invention relates to a decentralized electric energy trading system based on blockchain, comprising:

[0065] A transaction planning module is used to prioritize the end-to-end power transaction market between nodes with the closest electrical distance, calculate the electrical distance according to the topological structure and node location in the network, and sort the prosumers according to the minimum electrical distance;

[0066] User data module, used to create user data blocks with unique identity hashes;

[0067] Smart contracts, including master smart contracts, end-to-end smart contracts and P2G smart contracts; the master smart contract verifies the market participation of each node through the end-to-end smart contract until the market is cleared; due to the reduction of power loss, the minimum electrical distance strategy is used as the basis for each peer interaction in the energy trading mechanism; after the market is cleared, the master smart contract coordinates with the P2G smart contract to clear the market;

[0068] Wherein, the user data block is sent to the smart contract to meet pre-defined rules.

[0069] The third aspect of the present invention relates to a computer-readable storage medium storing instructions, which, when executed, implement the above-mentioned blockchain-based decentralized electricity trading method.

[0070] Beneficial Effects

[0071] Compared with the prior art, the present invention designs three smart contracts for the smooth operation of end-to-end energy transactions in the local market. The main smart contract is responsible for the verification of market participants and the storage and update of user data blocks. The end-to-end smart contract manages local energy transactions between nodes before the market is cleared, and the P2G smart contract manages the power transactions from prosumers to the grid. The end-to-end smart contract is formulated based on electrical distance to minimize transmission losses. This maximizes the profits of prosumers and reduces consumer consumption without compromising consumer comfort. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0073] Figure 1 It is a schematic diagram of the method flow of the present invention;

[0074] Figure 2 It is the IEEE 5-node system model;

[0075] Figure 3 It is the power price signal of the power grid;

[0076] Figure 4 excess power availability for prosumers and consumer demand;

[0077] Figure 5 For interaction based on electrical distance;

[0078] Figure 6 Provide an end-to-end cost-benefit analysis. DETAILED DESCRIPTION

[0079] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0080] like Figure 1 As shown in the figure, the decentralized electricity trading method based on blockchain includes the following steps:

[0081] (1) It is proposed to give priority to the end-to-end power trading market between nodes with close electrical distances, calculate the electrical distance based on the topological structure and node location in the network, and sort the producers and consumers according to the minimum electrical distance;

[0082] (2) Create a user data block with a unique identity hash. This data block is sent to the smart contract to satisfy the pre-established rules;

[0083] (3) Design three types of smart contracts including master smart contract, end-to-end smart contract and P2G smart contract; explain the interaction steps between peers and smart contracts;

[0084] (4) A 5-node test system consisting of 2 users and 3 prosumers was used to verify the proposed method.

[0085] The technical solution of the present invention is described in detail below:

[0086] Step 1: Build an end-to-end electricity trading market that prioritizes nodes with shorter electrical distances, calculate the electrical distance based on the topological structure and node location in the network, and sort the producers and consumers based on the minimum electrical distance.

[0087] (11) Based on the end-to-end power trading market between nodes with close electrical distances, the electrical distance is calculated according to the topological structure and node location in the network, and the producers and consumers are ranked according to the minimum electrical distance as shown in the following formula:

[0088] Elec_Dist ij =Z ii +Z jj -2Z ij

[0089] Where, is the electrical distance between nodes i and j, and Z represents the Z-node matrix. Transactions happen between the nodes that are closest to each other to reduce network losses.

[0090] After the market is cleared, the P2G smart contract is executed. Then the main smart contract updates the prosumer cost and consumer costs

[0091]

[0092]

[0093] Where: P t G2P Supply electricity to the grid to prosumers, is the grid price, is the market price of the same industry, P t P2G For prosumers to sell electricity to the grid, P t cons / pros It is for producers and consumers to sell or purchase electricity from their peers.

[0094] Step 2: Create a block of user data with a unique identity hash. This block of data is sent to the smart contract to satisfy pre-defined rules.

[0095] (21) A user data block with a unique identity hash is created. This data block is sent to the smart contract to satisfy the pre-established rules. After the data block is created, the master smart contract verifies the data blocks and adds them to the blockchain. In addition, the participants interact with the peer-to-peer smart contract until the market clearing time and then interact with the P2G smart contract. Since consumers and prosumers can interact with peers as well as the grid, the proposed system evolves into a hybrid energy market.

[0096] The first step in formula derivation is the design and verification of data blocks. In the electricity trading market, smart meters are used to collect various electrical values ​​to create these data blocks.

[0097] 1) Buyer data block: consists of node number, security key, category type, timestamp, and power requirement. The security key is a unique hash value, the category represents the alert or measurement of the data, the power requirement is the power required by the buyer, the timestamp is the exact moment when the block was added, and the cost represents the energy cost of the main smart contract update.

[0098] 2) Seller data block: It has similar information to the buyer data block except for the power availability information. It contains the excess power available for sale, and other information is the price of the sold power and the profit earned by the seller updated by the main smart contract. For the seller data block and buyer data block fields, the values ​​of the available power and its price for the seller interaction in the end-to-end energy trading market are defined.

[0099] Step 3: The three types of smart contracts include the main smart contract, the end-to-end smart contract and the P2G smart contract.

[0100] (31) The master smart contract verifies the market participation of each node through the end-to-end smart contract until the market is cleared. Due to the reduction in power loss, the minimum electrical distance strategy is used as the basis for each peer interaction in the energy trading mechanism. After the market is cleared, the master smart contract coordinates with the P2G smart contract to clear the market.

[0101] (32) The main smart contract algorithm is as follows: After creating a data block, the main contract algorithm verifies all users and calculates transactions based on the minimum electrical distance.

[0102] Below is a basic verification and main smart contract flow involving the interaction between buyers and sellers and data verification on the blockchain.

[0103] 1) Input user request: At the beginning, the system receives a request and determines which user initiated the request.

[0104] 2) If the user is a buyer: If the user is a buyer, the system will ask for the buyer’s data and perform block verification on the buyer’s data.

[0105] 3) If the user is a seller: If the user is a seller, the system will ask for the seller’s data and perform block verification on the seller’s data.

[0106] 4) Block verification buyer / seller: Verify the data of buyers and sellers respectively. If the category of the data is "measurement", set 'verifiednode' to true, otherwise set it to false.

[0107] 5) Start end-to-end interaction: Start end-to-end (PEE) interaction, which refers to direct interaction or communication between buyers and sellers.

[0108] 6) Check market settlement time: The system will check whether the market settlement time has passed.

[0109] 7) If the market settlement time has ended, the system will further check the energy situation.

[0110] 8) Energy detection: Perform P2G operations to process energy shortage and energy surplus.

[0111] 9) Ending condition: The ending condition is the result of checking the market settlement time and energy situation.

[0112] (33) The end-to-end smart contract algorithm is as follows:

[0113] The following is the process of an end-to-end smart contract involving an energy transaction between a buyer and a seller.

[0114] 1) Input buyer user i: The system receives the buyer’s information.

[0115] 2) Loop over j: Loop through potential sellers j.

[0116] 3) Calculate the electrical energy distance between buyer i and seller j.

[0117] 4) End the loop: Complete the distance calculation for all potential sellers.

[0118] 5) Calculate the minimum energy distance: Determine the seller closest to the buyer among all sellers, that is, the minimum energy distance.

[0119] 6) Record the bids between buyer i and seller j: The system records the bids between the buyer and the most recent seller.

[0120] 7) Check if the seller’s power supply is large enough to meet the buyer’s needs.

[0121] 8) Update the electricity and fees of the seller and buyer: If the seller has enough electricity, the system will reduce the seller's electricity and calculate the buyer's fee, while increasing the seller's profit.

[0122] 9) Buyer’s battery level is reset to zero: If the seller’s battery level is sufficient, the buyer’s battery level will be reset to zero, indicating that the transaction is complete.

[0123] 10) Otherwise: If the seller’s electricity is not enough to meet the buyer’s demand, the system will calculate the fee based on the amount of electricity purchased by the buyer and update the seller’s profit.

[0124] 11) Ending conditions: After the transaction is completed, the system will end this process.

[0125] (34) The P2G smart contract algorithm is as follows:

[0126] The following describes the process of handling energy supply and demand imbalance in the P2G smart contract.

[0127] 1) If the energy is insufficient: When the system detects that the energy supply is insufficient, the following operations are performed.

[0128] 2) Calculate the buyer’s fee: The buyer calculates the fee based on the grid electricity price and the amount of electricity purchased.

[0129] 3) Setting the buyer’s power to zero: Due to insufficient energy supply, the buyer’s power is set to zero, indicating that the transaction cannot be completed.

[0130] 4) If there is excess energy: When the system detects that the energy supply is sufficient, the following operations are performed.

[0131] 5) Calculate the seller’s profit: The seller calculates the profit based on the grid electricity price and the amount of electricity sold.

[0132] 6) Set the seller’s electricity to zero: Since there is excess energy, the seller’s electricity is set to zero, indicating that all the remaining electricity has been sold.

[0133] (35) The steps for peer interaction with smart contracts are as follows:

[0134] 1) Market participants buyers / sellers interact with the master smart contract to participate in electricity trading. A separate data block is created for each participant.

[0135] 2) After the block is created, the master smart contract verifies each participant by checking their unique identity hash and category (measurement / alarm). Once the user is verified, the master smart contract checks the status of the end-to-end smart contracts.

[0136] 3) Before the market clears, the master smart contract forwards the request and information of energy buying or selling to the end-to-end smart contract. If the request comes after this, the master contract rejects the request.

[0137] 4) During the end-to-end smart contract processing before the market clears, all possible node matching combinations are selected, and the matching with the smallest electrical distance is selected. This leads to a reduction in transmission losses. This process is repeated until the market clears.

[0138] 5) After the market is cleared, the power consumption and bills of each user are updated. The remaining power information related to the power demand of the prosumer and consumer is sent to the P2G smart contract.

[0139] 6) P2G informs buyers of the current grid price and sellers of the current grid price, which can be purchased by the utility grid. In this way, electricity demand is met by purchasing excess generation from prosumers through P2G interaction.

[0140] 7) Consumers pay the cost of energy use, while prosumers receive credits by selling their excess generation to peers and the utility grid.

[0141] 8) Market participants continue to participate in transactions through these smart contracts.

[0142] Step 4: A 5-node test system consisting of 2 users and 3 prosumers is used to verify the proposed method.

[0143] (41) The network diagram of the 5-node system is shown in Figure 2. Assume that 2 consumers are located at nodes 1 and 2, and 3 prosumers are located at nodes 3, 4, and 5. The electrical distance between each consumer and each prosumer is calculated, and transactions are made based on the minimum electrical distance to the prosumers and the power availability.

[0144] (42) Figure 3The electricity price signal for the day is given. The period from 19:00 to 20:00 is the peak period that causes the grid electricity price to increase and the user's electricity consumption pattern to change.

[0145] (43) The excess energy of prosumers is used to meet the energy needs of consumers through peer-to-peer trading. The availability of excess energy and demand patterns are as follows: Figure 4 As shown. Assume that the prosumer uses rooftop solar energy as the only source, so its power generation is mainly concentrated between 9:00 and 16:00. Assume that each panel has 54 1480×1000mm cells. Each small unit can collect a maximum energy of 250Wh, and 48 photovoltaic cells are assembled on a solar panel with a maximum energy of 12kWh. Consider the same data for all three prosumers.

[0146] (44) Establish a local end-to-end trading mechanism to interact between consumers and prosumers to meet their needs. Users can purchase electricity from prosumers or from the grid. The standard for interaction between prosumers and consumers is based on the minimum electrical distance. Figure 5 Describes the unit electrical distance between each prosumer and the consumer. This criterion can reduce network losses by interacting with the nearest node. Based on electrical distance, consumer C1 interacts with prosumer P1 first, followed by P3, and then P2; while consumer C2 interacts with prosumer P1 first, followed by P2, and then P3.

[0147] (45) Prosumers interact in an end-to-end mode to ensure that the end-to-end price is less than the grid price. In the proposed end-to-end framework, prosumers P1, P2, and P3 sell electricity at 12 EUR, 14 EUR, and 13 EUR, respectively. The set price is between the feed-in-tariff (FiT) rate and the time-of-use (ToU) price provided by the power company.

[0148] (46) Figure 5 and 6 As shown in Figure 1, by using the electrical distance method for end-to-end energy trading, consumers' energy costs are reduced and prosumers' profits are increased. This is because network losses are reduced by selling the maximum power in the vicinity. Figure 6 As shown in Figure 1, prosumers have excess energy between 9:00 and 16:00, which can be sold to consumers at a price lower than the grid price. Therefore, consumers benefit from end-to-end interaction.

[0149] In addition, from 9:00 to 16:00 hours, prosumers benefit more from peer-to-peer interaction than from only participating in P2G interaction because the price of peer-to-peer energy trading exceeds the FiT rate. Therefore, the system incentivizes prosumers to participate in peer-to-peer interaction. Since the pricing mechanism of the hybrid peer-to-peer trading system is that the price of electricity purchased from prosumers is always less than the price of the main grid. Therefore, it can be inferred from the simulation results that the nodes (consumers and prosumers) participating in the hybrid peer-to-peer trading system are economically beneficial.

[0150] The electrical distance of each consumer to each prosumer is calculated and transactions are made based on the minimum electrical distance to the prosumers and the availability of electricity. By using the electrical distance method for end-to-end energy trading, the energy cost of consumers is reduced and the profit of prosumers is increased. This is due to the reduction of network losses by selling the maximum power in the near area.

[0151] In summary, the economic benefits of a hybrid peer-to-peer energy trading market have been demonstrated through the implementation of blockchain technology. A fully decentralized peer-to-peer energy trading market is implemented without the involvement of any central entity. Three smart contracts are designed for the smooth operation of peer-to-peer energy trading in the local market. The master smart contract is responsible for the verification of market participants and the storage and update of user data blocks. The peer-to-peer smart contract manages local energy transactions between nodes before the market is cleared, and the P2G smart contract manages electricity transactions from prosumers to the grid. The peer-to-peer smart contracts are formulated based on electrical distances to minimize transmission losses. This maximizes the profits of prosumers and reduces the consumption expenditure of consumers without compromising their comfort.

[0152] The above shows and describes the basic principles, main features and advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited by the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, and these changes and improvements all fall within the scope of the present invention to be protected.

Claims

1. A decentralized electric energy trading method based on blockchain, characterized in that: The following steps are involved: Prioritize the end-to-end power trading market between nodes with the closest electrical distance, calculate the electrical distance according to the topological structure and node location in the network, and sort the prosumers according to the minimum electrical distance; Creating a block of user data with a unique identity hash, which is sent to a smart contract to satisfy pre-established rules; The smart contracts include a main smart contract, an end-to-end smart contract and a P2G smart contract; the main smart contract verifies the market participation of each node through the end-to-end smart contract until the market is cleared; after the market is cleared, the main smart contract and the P2G smart contract coordinate to clear the market.

2. The decentralized electric energy trading method based on blockchain according to claim 1, characterized in that: The end-to-end power trading market between nodes with a short electrical distance is given priority, the electrical distance is calculated according to the topological structure and node position in the network, and the producers and consumers are sorted according to the minimum electrical distance as shown in the following formula: Elec_Dist ij =Z ii +Z jj -2Z ij Among them, Elec_Dist ij is the electrical distance between nodes i and j, Z represents the Z-node matrix; After the market is cleared, the P2G smart contract is executed; Main smart contract updates prosumer costs and consumer costs Where: Supply electricity to the grid to prosumers, is the grid price, is the market price of the same industry, Selling electricity to the grid for prosumers, It is for producers and consumers to sell or purchase electricity from their peers.

3. The decentralized electric energy trading method based on blockchain according to claim 1, characterized in that: After the user data block is created, the main smart contract verifies the user data block and adds it to the blockchain; Participants interact with the peer-to-peer smart contract until market clearing time, and then interact with the P2G smart contract.

4. The decentralized electric energy trading method based on blockchain according to claim 1, characterized in that: The user data block includes: The buyer's data block includes the node number, security key, category type, timestamp, and power requirement; the security key is a unique hash value, the category represents the alert or measurement of the data, the power requirement is the power required by the buyer, the timestamp is the exact moment when the block was added, and the cost represents the energy cost of the main smart contract update; The seller data block includes power availability information, information similar to the buyer data block, excess power available for sale, the price of the sold power and the profit earned by the seller updated by the main smart contract; for the seller data block and buyer data block fields, the values ​​of the available power and its price for seller interaction in the end-to-end energy trading market are defined.

5. The decentralized electric energy trading method based on blockchain according to claim 1, characterized in that: The workflow of the master smart contract involves the interaction between buyers and sellers and data verification on the blockchain, including the following steps: 1) At the beginning, the system receives a request and determines which user initiated the request; 2) If the user is a buyer, the system will ask for the buyer’s data and perform block verification on the buyer’s data; 3) If the user is a seller, the system will ask for the seller’s data and perform block verification on the seller’s data; 4) Block verification buyer / seller: Verify the buyer and seller data separately. If the category of the data is "measurement", set 'verifiednode' to true, otherwise set it to false; 5) Start end-to-end interaction, which refers to direct interaction or communication between buyers and sellers; 6) Check market settlement time: The system will check whether the market settlement time has passed; 7) If the market settlement time has ended, the system will further check the energy situation; 8) Energy detection: Perform P2G operations to process energy shortage and energy surplus; 9) Ending condition: The ending condition is the result of checking the market settlement time and energy situation.

6. The decentralized electric energy trading method based on blockchain according to claim 1, characterized in that: The working process of the end-to-end smart contract involves the transaction of electric energy between the buyer and the seller, and includes the following steps: 1) Input buyer user i: the system receives the buyer’s information; 2) Loop over j: Loop through potential sellers j; 3) Calculate the electrical energy distance between buyer i and seller j; 4) End the loop: complete the distance calculation for all potential sellers; 5) Calculate the minimum energy distance: determine the seller closest to the buyer among all sellers, that is, the minimum energy distance; 6) Record the bids between buyer i and seller j: The system records the bids between the buyer and the most recent seller; 7) Check whether the seller’s electricity is large enough to meet the buyer’s needs; 8) If the seller has enough electricity, the system will reduce the seller's electricity and calculate the buyer's fee, while increasing the seller's profit; 9) If the seller has enough power, the buyer's power will be reset to zero, indicating that the transaction is complete; 10) If the seller’s electricity is not enough to meet the buyer’s demand, the system will calculate the fee based on the amount of electricity purchased by the buyer and update the seller’s profit; 11) Ending conditions: After the transaction is completed, the system will end this process.

7. The decentralized electric energy trading method based on blockchain according to claim 1, characterized in that: The workflow of the P2G smart contract involves the process of handling the imbalance between energy supply and demand, including the following steps: 1) When the system detects insufficient energy supply, it performs the following operations; 2) Buyers calculate the fee based on the grid electricity price and the amount of electricity purchased; 3) Due to insufficient energy supply, the buyer’s power is set to zero, indicating that the transaction cannot be completed; 4) When the system detects that the energy supply is sufficient, it performs the following operations; 5) The seller calculates the profit based on the grid electricity price and the amount of electricity sold; 6) Due to the excess energy, the seller’s electricity is set to zero, indicating that all the remaining electricity has been sold.

8. The decentralized electric energy trading method based on blockchain according to claim 2, characterized in that: The steps for the interaction between the peer and the smart contract are as follows: 1) Market participants buyers / sellers interact with the master smart contract to participate in electricity trading; a separate data block is created for each participant; 2) After the block is created, the main smart contract verifies each participant by checking their unique identity hash and category; once the user is verified, the main smart contract checks the status of the end-to-end smart contracts; 3) Before the market clears, the master smart contract forwards the request and information of energy buying or selling to the end-to-end smart contract; if the request comes after that, the master contract rejects the request; 4) During the end-to-end smart contract processing before the market clears, all possible node matching combinations are selected, and the match with the smallest electrical distance is selected; this process is repeated until the market clears; 5) After the market is cleared, the electricity consumption and bills of each user are updated; The remaining power information related to the power demand of prosumers and consumers is sent to the P2G smart contract; 6) P2G informs buyers of the current grid price and sellers of the current grid price, which can be purchased by the utility grid; in this way, electricity demand is met by purchasing excess generation from prosumers through P2G interaction; 7) Consumers pay the cost of energy use, while prosumers receive credits by selling their excess generation to peers and the utility grid; 8) Market participants continue to participate in transactions through these smart contracts.

9. A decentralized electric energy trading system based on blockchain, characterized in that: include: A transaction planning module is used to prioritize the end-to-end power transaction market between nodes with the closest electrical distance, calculate the electrical distance according to the topological structure and node location in the network, and sort the prosumers according to the minimum electrical distance; User data module, used to create user data blocks with unique identity hashes; Smart contracts, including master smart contracts, end-to-end smart contracts and P2G smart contracts; the master smart contract verifies the market participation of each node through the end-to-end smart contract until the market is cleared; due to the reduction of power loss, the minimum electrical distance strategy is used as the basis for each peer interaction in the energy trading mechanism; after the market is cleared, the master smart contract coordinates with the P2G smart contract to clear the market; Wherein, the user data block is sent to the smart contract to meet pre-defined rules.

10. A computer-readable storage medium storing instructions, characterized in that: When the instruction is executed, the decentralized electricity trading method based on blockchain described in any one of claims 1 to 8 is implemented.