Micro-time scale electric energy transaction metering system and method based on smart contract
Through the electric energy trading metering system based on smart contracts, the centralized management and data tampering risks of the electric energy dispatching system are solved, the automation, transparency and security of electric energy trading are achieved, and the reliability and transaction efficiency of the system are improved.
Patent Information
- Application Number
- CN202510700255.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-09-12
AI Technical Summary
The existing power dispatching system has problems such as centralized management, data tampering risks, and transaction opacity.
A micro-timescale electricity trading metering system based on smart contracts is adopted. Through smart meters, electricity distribution controllers, smart contracts and electricity distributors, automatic matching of power generation sources and power loads and recording and chain storage of electricity trading data are achieved, and blockchain technology is used to ensure the transparency and security of transactions.
It realizes the automation, transparency and security of electricity trading, improves the reliability and credibility of the system, and quickly processes electricity trading data through the PBFT consensus algorithm, improving the efficiency and flexibility of transactions.
Smart Images

Figure CN120634552A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a micro-timescale electric energy transaction metering system and method based on smart contracts. Background Art
[0002] The invention patent application with publication number CN118676929A and invention name is Micro-time scale electric energy distribution and scheduling method, device and power scheduling array, and the invention patent application with publication number CN118353080A and invention name is Power supply method, device, electronic equipment, storage medium and product, both involve the concept of differential time scale electric energy distribution and scheduling, but the electric energy scheduling system has problems such as centralized management, data tampering risk and transaction opacity. Summary of the Invention
[0003] In response to the problems of centralized management, data tampering risks, and transaction opacity in existing electric energy dispatching systems, the present invention proposes a micro-timescale electric energy trading metering system and method based on smart contracts. Smart contracts are used to achieve automatic matching of sources and loads and the recording and on-chain storage of electric energy trading data.
[0004] In order to achieve the above object, the present invention adopts the following technical solutions:
[0005] On one hand, the present invention proposes a micro-timescale electric energy transaction metering system based on smart contracts, comprising: a smart meter, an electric energy distribution controller, a smart contract and an electric energy distributor;
[0006] The smart meter is used to measure the power generation of the power source and the power required by the power load in real time, and transmit the power generation and power consumption information to the blockchain network;
[0007] The power distribution controller extracts the transaction results after consensus is uploaded to the chain by each node, interprets them into power channel instructions for opening or closing corresponding power generation sources and power loads, and then sends the actual power distribution instructions to the power distributor;
[0008] The smart contract is used to receive power data from power generation sources and power loads, and execute the scheduling algorithm to match power generation sources and power loads. Each node calls and generates power transaction records, which are verified by node consensus to ensure the correctness and immutability of the process.
[0009] The power distributor is used to complete the connection between the power generation source and the power load according to the actual power distribution instruction issued by the power distribution controller;
[0010] The smart meter and electric energy distribution controller both have storage and computing capabilities, can store certificates and keys, complete blockchain communication, and participate in rapid consensus as blockchain nodes.
[0011] Furthermore, the smart meter or the energy distribution controller is configured as follows:
[0012] Before joining the blockchain network, generate a private and public key pair, register with a trusted third party, and apply for a digital certificate for the public key;
[0013] The public key is sent to the blockchain node of the control center, and its own private key is stored. After the identity information is verified by the blockchain node, an identity identifier is created and the identity identifier is associated with the public key and stored;
[0014] Install software that supports blockchain communication.
[0015] Furthermore, when sending data, the smart meter or electric energy distribution controller uses its own private key to sign the data, and other nodes use the corresponding public key to verify after receiving the data.
[0016] Another aspect of the present invention provides a micro-timescale electric energy transaction metering method based on smart contracts, comprising:
[0017] Smart meters measure power generation from power sources or load power consumption in real time, transmit this information to the blockchain network, and then match transactions through smart contracts.
[0018] The smart contract processes the power data of the power generation source and the power load according to the preset scheduling algorithm to obtain the source-load matching solution;
[0019] After the source and load are successfully matched, the smart contract generates an energy transaction record and records transaction-related information;
[0020] All nodes verify the legitimacy of the energy transaction and confirm it through a consensus algorithm, and store the verified energy transactions on the blockchain;
[0021] The power distribution controller reads the transaction information added to the block, converts it into switch control instructions, and sends it to the power distributor for actual distribution of electricity.
[0022] Furthermore, the scheduling algorithm includes:
[0023] During the dispatching process, priority is given to the use of renewable energy power generation sources; one power generation source can provide electricity to multiple power loads at the same time; one power load can only be supplied by one power generation source at a time; the basis for matching one power generation source and one or more power loads is that the total capacity of the power generation source is within 0.9 or 1.1 times the power of the total power load; when the renewable energy power generation source cannot meet the power load demand, the large power grid will provide supplementary electricity; the power generation source that cannot complete the matching will not be supplied to the power load.
[0024] Furthermore, the consensus algorithm is a PBFT consensus algorithm.
[0025] Furthermore, during the electricity dispatch process, the electricity load initiates a transaction request through the smart contract, and the transaction request is broadcast to all nodes; after receiving the request, the node ensures that the consensus is reached within T seconds through the PBFT consensus algorithm; once the transaction passes the consensus, the smart contract is automatically executed, and according to the scheduling algorithm, new energy is given priority for source-load matching, and a transaction record is generated; finally, the transaction record is written into the block, and all nodes verify and accept the block to ensure the immutability of the transaction.
[0026] Compared with the prior art, the present invention has the following beneficial effects:
[0027] Realize automatic, transparent and secure transactions of electric energy: Through smart contracts, automatic matching of sources and loads and recording and on-chain storage of electric energy transaction data are achieved, ensuring the automation, transparency and security of the transaction process.
[0028] Solve the problems of traditional power dispatching system: It effectively solves the problems of centralized management, data tampering risks and transaction opacity in traditional power dispatching system, and improves the reliability and credibility of the system.
[0029] Improve the efficiency and flexibility of electricity trading: The consensus algorithm based on PBFT fast block generation can quickly process electricity trading data and quickly upload the electricity trading data of the previous time slice to the chain, thereby improving the efficiency and flexibility of electricity trading. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is a schematic diagram of the architecture of a micro-timescale electric energy transaction metering system based on smart contracts according to an embodiment of the present invention;
[0031] Figure 2 This is a flowchart for constructing a micro-timescale electric energy trading metering system based on smart contracts in an embodiment of the present invention.
[0032] Figure 3 This is a flow chart of a micro-timescale electric energy transaction metering method based on smart contracts according to an embodiment of the present invention;
[0033] Figure 4 A schematic diagram of on-chain storage for electric energy transactions provided by an embodiment of the present invention;
[0034] Figure 5 A schematic diagram of transaction information provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0035] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments:
[0036] like Figure 1 As shown in FIG, a micro-timescale electric energy transaction metering system based on smart contracts includes:
[0037] (1) Smart meter: measures the power generation of the power source and the power required by the power load in real time, calls the depositEnergy function (allowing users or devices to deposit energy into the system) and the purchaseEnergy function (allowing other users to purchase energy from the system) of the smart contract, and transmits the power generation and consumption information to the blockchain network; at the same time, the smart meter has a certain storage and computing capacity, can store certificates and keys, complete blockchain communication, and participate in rapid consensus as a blockchain node.
[0038] (2) Power distribution controller: extracts the transaction results after each node consensus is uploaded to the chain, parses them into instructions for opening or closing the power channel corresponding to the power generation source and power load, and then sends the actual power distribution instructions to the power distributor; it has certain storage and computing capabilities, can store certificates and keys, complete blockchain communication, and participate in rapid consensus as a blockchain node.
[0039] (3) Smart contract (including scheduling algorithm): A program running on the blockchain (including depositEnergy function and purchaseEnergy function), which receives the power data of power generation sources and power loads, and executes the scheduling algorithm to match the power generation sources and power loads; each node calls and generates power transaction records, and the power transaction records are verified by node consensus to ensure the correctness and non-tamperability of the process.
[0040] (4) Power distributor: electrical equipment, actual power transmission and distribution cabinet, which completes the connection between power generation source and power load.
[0041] Furthermore, if Figure 2 As shown, the system construction process is as follows:
[0042] Smart meter configuration or energy distribution controller configuration:
[0043] (1) Registration and identity authentication: Before joining the blockchain network, smart meters or energy distribution controllers need to generate a key pair (including private and public keys), register with a trusted third party, and apply for a digital certificate for the public key;
[0044] (2) Key management: Smart meters and power distribution controllers send public keys to the blockchain node of the control center, which stores their respective private keys securely through hardware. After the blockchain node verifies the identity information of the smart meters and power distribution controllers, it creates identity identifiers for the smart meters and power distribution controllers and associates the identity identifiers with the public keys for storage.
[0045] (3) Install software that supports blockchain communication in smart meters and power distribution controllers to enable interaction with the blockchain network, data storage, and transaction processing.
[0046] (4) When sending data, the smart meter or power distribution controller uses its own private key to sign the data to ensure the integrity and authenticity of the data. After other nodes receive the data, they use the corresponding public key to verify it.
[0047] Blockchain construction and smart contract writing:
[0048] (1) Build a blockchain platform.
[0049] (2) Write a smart contract to define the matching rules between power generation sources and power loads, the terms of power transactions, and the interface with the scheduling algorithm, and deploy the contract to the blockchain platform.
[0050] (3) Start the node and connect to the blockchain network.
[0051] (4) Deploy the contract: Use a deployment tool (such as Remix IDE) to deploy the compiled bytecode to the blockchain network, exposing the calling interface and contract address.
[0052] Based on the above embodiments, Figure 3 As shown, the present invention also proposes a micro-timescale electric energy transaction metering method based on smart contracts, including:
[0053] Smart meters measure power generation from power sources or load power consumption in real time, transmit this information to the blockchain network, and then match transactions through smart contracts.
[0054] The smart contract processes the power data of the power generation source and the power load according to the preset scheduling algorithm to obtain the source-load matching solution;
[0055] After the source and load are successfully matched, the smart contract generates an energy transaction record and records transaction-related information;
[0056] All nodes verify the legitimacy of the energy transaction and confirm it through a consensus algorithm, and store the verified energy transactions on the blockchain;
[0057] The power distribution controller reads the transaction information added to the block, converts it into switch control instructions, and sends it to the power distributor for actual distribution of electricity.
[0058] Furthermore, the method specifically includes:
[0059] 1) Data collection and preprocessing
[0060] Smart meters measure data such as power generation from power sources or power consumption from loads (such as voltage, current, and power) in real time. Smart meters transmit power generation and consumption information to the blockchain network by calling the depositEnergy and purchaseEnergy functions, and then match transactions through smart contracts.
[0061] 2) Calling and running smart contracts
[0062] (1) Triggering the smart contract: Before the start of each scheduling cycle T, all data on power generation sources and power loads are written into the blockchain through the depositEnergy and purchaseEnergy functions; the power load power request and the power supply information of the power generation source will be broadcast to all nodes in the blockchain network. Each node will match transactions according to the matching logic preset in the smart contract. The node will try to find the most suitable combination of power generation sources and power loads to meet the energy consumption / supply needs of all participants.
[0063] (2) Execution of the scheduling algorithm: The smart contract processes the power data of the power generation source and the power load according to the preset scheduling algorithm to obtain a source-load matching solution.
[0064] (3) Generate transaction records: After the source and load are successfully matched, the smart contract generates an electricity transaction record, recording information such as the transaction parties, transaction volume, and transaction price.
[0065] (4) Blockchain verification: All nodes verify the legitimacy of the transaction and confirm it through a consensus algorithm.
[0066] 3) Scheduling Algorithms in Smart Contracts
[0067] In the system proposed by this invention, the scheduling algorithm in the smart contract needs to meet the following requirements:
[0068] (1) During the dispatching process, priority should be given to the use of new energy sources (such as solar energy, wind energy, etc.) to reduce dependence on the large power grid and maximize the utilization of green energy.
[0069] (2) A power generation source can provide electricity to multiple power loads at the same time.
[0070] (3) An electrical load can only be supplied by one power source at a time.
[0071] (4) The basis for matching a power generation source with one or more power loads is that the total capacity of the power generation source is within 0.9 or 1.1 times the total power load power to ensure the stability and safety of power supply.
[0072] (5) When the renewable energy power source cannot meet the power load demand, the large power grid will provide supplementary power to ensure the continuity of power supply.
[0073] (6) The power generation source cannot be matched and cannot supply the power load.
[0074]
[0075] 4) Transaction verification and on-chain
[0076] (1) Transaction broadcast: The transaction record obtained by each node calling the smart contract is broadcast to all nodes in the blockchain network (such as smart meters or power distribution controllers).
[0077] (2) Transaction verification and consensus: Nodes verify transaction records and reach consensus through a consensus algorithm to ensure the legitimacy and immutability of transactions.
[0078] (3) Transaction on-chain: Verified transactions are packaged into blocks and added to the blockchain, completing the on-chain storage of power transactions, such as Figure 4 shown.
[0079] 5) Fast consensus algorithm
[0080] During the electricity dispatch process, the electricity load initiates a transaction request through a smart contract. For example, if load 1 requests 90kW of electricity, the transaction request is broadcast to all nodes. After receiving the request, the node uses the PBFT (Practical Byzantine Fault Tolerance) consensus algorithm to ensure that consensus is reached within T seconds. Once the transaction passes consensus, the smart contract is automatically executed, and according to the scheduling algorithm, new energy sources are prioritized for source-load matching, and a transaction record is generated. Finally, the transaction record is written into the block, and all nodes verify and accept the block to ensure that the transaction cannot be tampered with.
[0081] PBFT consensus algorithm consensus process:
[0082] (1) Block Packaging Stage
[0083] The master node (node0) is randomly selected. After receiving the transaction matching results, the master node (node0) packages these requests into a new block and assigns a unique serial number to the block.
[0084] The other nodes (node1, node2, node3) are in a waiting state, ready to receive messages broadcast by the master node.
[0085] (2) Pre-prepare stage
[0086] The master node broadcasts a pre-prepare message to all other nodes. The message contains relevant information about the new block, such as serial number, hash value, etc.
[0087] After receiving the pre-prepare message, other nodes will perform a series of checks, such as the legitimacy of the message, whether they have received the same pre-prepare message before, etc. If the checks pass, the backup node will record the message and prepare to enter the next stage.
[0088] (3) Prepare stage
[0089] After receiving the pre-prepare message and checking it, other nodes will broadcast a prepare message to all remaining nodes to indicate that they are ready.
[0090] After receiving a sufficient number of prepare messages (at least 2f+1), the master node will record these messages and prepare to enter the next stage.
[0091] After receiving a sufficient number of prepare messages, other nodes will also record these messages and prepare to enter the next stage.
[0092] (4) Commit stage
[0093] After receiving a sufficient number of prepare messages, other nodes will broadcast a commit message to all remaining nodes, indicating that they are ready to submit the block.
[0094] After receiving a sufficient number of commit messages (at least 2f+1), the master node will record these messages and finally determine that the block can be committed.
[0095] After receiving a sufficient number of commit messages, all remaining nodes will also record these messages and finally determine that the block can be committed.
[0096] (5) Block placement stage
[0097] After the commit phase, all nodes will write the new block to their local blockchain database, completing the block storage operation. At the same time, the node will clean up related temporary data and caches to prepare for processing the next block.
[0098] Through the work in the above stages, the consensus algorithm based on PBFT fast block generation enables the electricity transaction data of the previous time slice to be quickly uploaded to the chain. The PBFT algorithm can ensure that even in the presence of malicious nodes, normal nodes in the system can still reach consensus, ensuring the consistency and security of the blockchain.
[0099] 6) Power transmission
[0100] The power distribution controller reads the transaction information added to the block, such as Figure 5 As shown, it is converted into a switch control instruction and sent to the power distributor.
[0101] In summary, the present invention:
[0102] 1. Electricity dispatch and trading mechanism based on smart contracts: Smart contracts automatically execute source-load matching and electricity trading, ensuring that transactions are automatically carried out when preset conditions are met, thereby improving transaction efficiency and transparency.
[0103] 2. PBFT fast block generation consensus algorithm: The PBFT consensus algorithm is used to quickly process electricity transaction data and quickly upload electricity transaction data of the previous time slice to the chain, ensuring the real-time and high efficiency of the system.
[0104] 3. Integration of smart meters with blockchain networks: Smart meters measure data on power generation sources and loads in real time, and transmit this data to the blockchain network by calling smart contract functions. They also possess storage and computing capabilities, enabling them to participate in rapid blockchain consensus.
[0105] 4. Interaction between the power distribution controller and the blockchain: The power distribution controller extracts the transaction results on the blockchain, converts them into power distribution instructions, and sends them to the power distributor to realize the actual distribution of electricity.
[0106] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A micro-timescale electric energy transaction metering system based on smart contracts, characterized in that: include: Smart meters, power distribution controllers, smart contracts and power distributors; The smart meter is used to measure the power generation of the power source and the power required by the power load in real time, and transmit the power generation and power consumption information to the blockchain network; The power distribution controller extracts the transaction results after consensus is uploaded to the chain by each node, interprets them into power channel instructions for opening or closing corresponding power generation sources and power loads, and then sends the actual power distribution instructions to the power distributor; The smart contract is used to receive power data from power generation sources and power loads, and execute the scheduling algorithm to match power generation sources and power loads. Each node calls and generates power transaction records, which are verified by node consensus to ensure the correctness and immutability of the process. The power distributor is used to complete the connection between the power generation source and the power load according to the actual power distribution instruction issued by the power distribution controller; The smart meter and electric energy distribution controller both have storage and computing capabilities, can store certificates and keys, complete blockchain communication, and participate in rapid consensus as blockchain nodes.
2. The micro-timescale electric energy transaction metering system based on smart contracts according to claim 1 is characterized in that: Configure the smart meter or energy distribution controller as follows: Before joining the blockchain network, generate a private and public key pair, register with a trusted third party, and apply for a digital certificate for the public key; The public key is sent to the blockchain node of the control center, and its own private key is stored. After the identity information is verified by the blockchain node, an identity identifier is created and the identity identifier is associated with the public key and stored; Install software that supports blockchain communication.
3. The micro-timescale electric energy transaction metering system based on smart contracts according to claim 1 is characterized in that: When sending data, the smart meter or electric energy distribution controller uses its own private key to sign the data. After other nodes receive the data, they use the corresponding public key to verify it.
4. A micro-timescale electric energy transaction measurement method based on smart contracts, characterized in that: include: Smart meters measure power generation from power sources or load power consumption in real time, transmit this information to the blockchain network, and then match transactions through smart contracts. The smart contract processes the power data of the power generation source and the power load according to the preset scheduling algorithm to obtain the source-load matching solution; After the source and load are successfully matched, the smart contract generates an energy transaction record and records transaction-related information; All nodes verify the legitimacy of the energy transaction and confirm it through a consensus algorithm, and store the verified energy transactions on the blockchain; The power distribution controller reads the transaction information added to the block, converts it into switch control instructions, and sends it to the power distributor for actual distribution of electricity.
5. The micro-timescale electric energy transaction measurement method based on smart contracts according to claim 1 is characterized in that: The scheduling algorithm includes: During the dispatching process, priority is given to the use of renewable energy power generation sources; one power generation source can provide electricity to multiple power loads at the same time; one power load can only be supplied by one power generation source at a time; the basis for matching one power generation source and one or more power loads is that the total capacity of the power generation source is within 0.9 or 1.1 times the power of the total power load; when the renewable energy power generation source cannot meet the power load demand, the large power grid will provide supplementary electricity; the power generation source that cannot complete the matching will not be supplied to the power load.
6. The micro-timescale electric energy transaction measurement method based on smart contracts according to claim 1 is characterized in that: The consensus algorithm is the PBFT consensus algorithm.
7. The micro-timescale electric energy transaction measurement method based on smart contracts according to claim 6 is characterized in that: During the electricity dispatch process, the electricity load initiates a transaction request through a smart contract, and the transaction request is broadcast to all nodes. After receiving the request, the node uses the PBFT consensus algorithm to ensure that consensus is reached within T seconds. Once the transaction passes the consensus, the smart contract is automatically executed, and according to the dispatch algorithm, new energy is prioritized for source-load matching, and a transaction record is generated. Finally, the transaction record is written into the block, and all nodes verify and accept the block to ensure the immutability of the transaction.
Citation Information
Patent Citations
Power supply method and device, electronic equipment, storage medium and product
CN118353080A
Micro-time scale electric energy distribution scheduling method and device and electric power scheduling array
CN118676929A