A virtual electric field automatic transaction settlement method using a blockchain smart contract
By generating digital identities within electricity metering devices through blockchain smart contracts and hardware security modules, creating energy contracts, and signing metering certificates in real time, the problems of data tampering and inefficiency in the traditional centralized settlement model are solved. This achieves reliable, transparent, and efficient settlement of electricity transactions, and improves the reliability of virtual power fields and the grid's interaction capabilities.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANDONG PANHAI OPTOELECTRONIC TECHNOLOGY CO LTD
- Filing Date
- 2025-12-01
- Publication Date
- 2026-07-07
AI Technical Summary
Traditional centralized settlement models struggle to guarantee the authenticity and reliability of metering data and the transparency and efficiency of the settlement process in distributed energy transactions. They also fail to provide real-time price signals and economic feedback, resulting in low capital turnover efficiency and an inability to effectively guide energy nodes to adjust their power generation or consumption behavior, thus weakening the virtual power field's support capacity for the power grid.
By employing blockchain smart contracts and hardware security modules, a digital identity is generated by embedding a unique private key in the power metering device. This creates an energy contract and initializes the performance warehouse state machine, generates a dynamic settlement contract, signs metering vouchers in real time, forms a trusted performance data stream, calculates performance deviation values, and generates dynamic adjustment instructions, thus forming a closed-loop settlement cycle.
It ensures the authenticity and immutability of electricity trading data, and guides trading participants to adjust their behavior through the real-time economic incentives or penalties of smart contracts, thereby improving the reliability of the virtual power field and its ability to interact with the power grid, and reducing transaction costs and resource consumption.
Smart Images

Figure CN121599766B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of power systems and relates to an automatic transaction settlement method for virtual electric fields using blockchain smart contracts. Background Technology
[0002] With the integration of distributed energy sources such as distributed photovoltaics, energy storage, and electric vehicle charging piles, virtual electric fields, as an effective form of aggregating and regulating these resources, face challenges in their internal electricity trading and settlement processes. These challenges include a massive number of trading entities, small-amount, high-frequency trading characteristics, and strict real-time requirements. This makes it difficult for traditional centralized settlement models to guarantee the authenticity and reliability of metering data, the transparency and efficiency of the settlement process, and the immediate and effective incentives for performance.
[0003] The solutions currently widely used in the industry still heavily rely on centralized operating platforms. These platforms collect metering data from various distributed energy nodes and then aggregate, reconcile, and clear funds within fixed settlement cycles. This model is essentially an extension of the traditional electricity settlement system in a distributed scenario, using a centralized database and back-end system to process transaction data and financial processes.
[0004] However, centralized platforms inherently pose single points of failure and trust risks. Data may be tampered with or misused, easily leading to transaction disputes. Long-cycle settlement models result in low capital turnover efficiency, making it impossible to provide participants with real-time price signals and economic feedback. This makes it difficult to effectively guide energy nodes to adjust their power generation or consumption behavior according to the real-time needs of the power grid, thus weakening the virtual power field's support capacity for the power grid. Summary of the Invention
[0005] To address the aforementioned problems, this invention provides a method for automatic transaction settlement of virtual electric fields using blockchain smart contracts.
[0006] A method for automatic transaction settlement of virtual electric fields using blockchain smart contracts includes the following steps:
[0007] S1. Integrate the hardware security module into the electricity metering device. The hardware security module has a built-in unique private key and registers the association between the public key corresponding to the hardware security module and the user's wallet address on the main settlement chain to generate a digital identity.
[0008] S2. Respond to transaction requests initiated based on digital identities, create energy contracts on the main settlement chain, and initialize the performance position state machine on the real-time matching metering chain. The state machine includes balanced, surplus, and deficit states, and generates dynamic settlement contracts.
[0009] S3. When the dynamic settlement contract enters the performance period, the hardware security module calls its internal private key to digitally sign the data packet containing the metering value and generate a signed metering certificate.
[0010] S4. After receiving the signed metering certificate, the real-time matching metering chain calls the public key registered on the main settlement chain to verify the signature, and converts the electricity information in the verified certificate into an on-chain record, forming a trusted performance data stream.
[0011] S5. Analyze the reliable performance data stream from the dynamic settlement contract on the real-time matching metering chain, calculate the difference between the theoretically required performance volume and the actual performance volume, and generate a real-time performance deviation value;
[0012] S6. The dynamic settlement contract triggers the state transition of the performance position state machine based on whether the real-time performance deviation value exceeds the preset threshold, and generates economic incentives or penalties based on the transitioned state, and generates dynamic adjustment instructions.
[0013] S7. Execute dynamic adjustment instructions to guide users to adjust their energy behavior through real-time cost changes or revenue incentives to reduce performance deviations and form a closed-loop settlement cycle;
[0014] S8. After the settlement cycle of the fact-closed loop ends, the metering chain summarizes the performance results and economic adjustments in real time to generate a final net settlement list for transaction settlement on the main settlement chain.
[0015] A further aspect of the present invention generates a digital identity, comprising the following steps:
[0016] Extract the public key corresponding to the hardware security module and bind it to the user's wallet address to the main settlement chain;
[0017] After the binding is completed, a digital identity is generated that combines the fingerprint of the physical device with the on-chain account.
[0018] A further aspect of the present invention generates a dynamic settlement contract, comprising the following steps:
[0019] Receive contract creation instructions, lock the assets of both parties on the main settlement chain, and record the total transaction volume, transaction duration, and digital identities of both parties;
[0020] Based on the contract information, deploy smart contract instances containing fulfillment position state machines on the real-time matching metering chain;
[0021] The initial state of the performance position state machine is set to balance, and the trigger threshold for the state to transition from balance to surplus or deficit is configured to generate a dynamic settlement contract to be executed.
[0022] A further aspect of the present invention generates a signed measurement certificate, comprising the following steps:
[0023] The hardware security module periodically or based on power change events collects raw metering data, including timestamps, cumulative power consumption, and current direction.
[0024] Pack the raw measurement data into a standard format data package;
[0025] The private key inside the hardware security module is used to digitally sign the data packet, generating a signed metering certificate.
[0026] A further aspect of the present invention, forming a trusted fulfillment data stream, includes the following steps:
[0027] Nodes in the real-time matching metering chain capture signed metering credentials.
[0028] Retrieve the corresponding public key from the main settlement chain based on the source index of the metering certificate;
[0029] The metering certificate is signed and verified using a public key, and the verified metering data is written into the block of the real-time matching metering chain to form a trusted performance data stream.
[0030] A further aspect of the present invention generates a real-time performance deviation value, comprising the following steps:
[0031] The actual amount of electricity supplied and consumed by both parties in the transaction is obtained by summing up the amount of electricity supplied based on the trusted performance data stream.
[0032] Calculate the theoretically due volume at the current time point based on the total transaction volume and total transaction duration.
[0033] The actual amount of electricity fulfilled is compared with the theoretical amount of electricity that should have been fulfilled, and a real-time performance deviation value is generated.
[0034] A further aspect of the present invention generates dynamic adjustment instructions, comprising the following steps:
[0035] If the real-time performance deviation value is positive and exceeds the profit threshold, the performance position status will be switched from balanced to profitable.
[0036] If the real-time performance deviation value is negative and exceeds the deficit threshold, the performance position status will be switched from balanced to deficit.
[0037] Dynamic adjustment instructions are generated based on the migrated status; these instructions include transaction fee discounts, transaction fee increases, or transaction priority reductions.
[0038] A further aspect of the present invention, forming a de facto closed-loop settlement cycle, includes the following steps:
[0039] Apply dynamic adjustment commands to subsequent user operations on the real-time matching metering chain;
[0040] Based on the user's proactive adjustment behavior, reverse adjustment is made to correct the contract performance status, thus forming a settlement cycle with a factual closed loop.
[0041] A further aspect of the present invention involves performing fund clearing, including the following steps:
[0042] Upon contract expiration, the dynamic settlement contract ceases to receive measurement vouchers;
[0043] Key settlement results are packaged and hashed to generate the final net settlement list;
[0044] The final net settlement list is sent to the main settlement chain for verification and fund clearing. Fund clearing includes the transfer, return or penalty of assets.
[0045] A further aspect of the present invention includes: comparing the real-time performance deviation value with a preset power grid stability contribution threshold; if the absolute value of the real-time performance deviation value is not greater than the power grid stability contribution threshold, then generating a stability contribution identifier; when generating a dynamic adjustment instruction, if the stability contribution identifier is detected, then reducing or increasing the economic penalty measures or increasing the economic incentive measures.
[0046] In summary, the present invention has the following beneficial technical effects:
[0047] 1. By using a hardware security module to perform source signature on each electricity meter reading, the authenticity and immutability of the data uploaded to the blockchain are ensured, reducing trust issues in transaction data and providing a data foundation for subsequent automated settlement processes.
[0048] 2. By continuously calculating performance deviations through smart contracts and triggering dynamic economic reward and punishment measures in real time, it is possible to effectively guide transaction participants to actively adjust their power generation or consumption behavior to comply with the contract. Through a closed-loop feedback mechanism, performance deviations tend to decrease, thereby improving the overall reliability of the virtual power field and its ability to interact with the power grid.
[0049] 3. By utilizing a dual-chain architecture, the efficiency of high-frequency metering data processing and the security of final asset settlement are ensured, reducing the need for manual intervention and the overall cost of transactions; by generating a lightweight final settlement list to complete the main chain liquidation, the consumption of computing and storage resources on the main chain is reduced. Attached Figure Description
[0050] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. The drawings are used to provide a further understanding of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0051] Figure 1A flowchart illustrating an embodiment of this application is disclosed.
[0052] Figure 2 Structural schematic diagrams of embodiments of this application are disclosed. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0054] The following is in conjunction with the appendix Figure 1 - Figure 2 A preferred description of the present invention is provided below.
[0055] See attached document Figure 1 This invention proposes an automatic transaction settlement method for virtual electric fields using blockchain smart contracts, comprising the following steps:
[0056] S1. Integrate the hardware security module into the electricity metering device. The hardware security module has a built-in unique private key and registers the association between the public key corresponding to the hardware security module and the user's wallet address on the main settlement chain to generate a digital identity.
[0057] S2. Respond to transaction requests initiated based on digital identities, create energy contracts on the main settlement chain, and initialize the performance position state machine on the real-time matching metering chain. The state machine includes balanced, surplus, and deficit states, and generates dynamic settlement contracts.
[0058] S3. When the dynamic settlement contract enters the performance period, the hardware security module calls its internal private key to digitally sign the data packet containing the metering value and generate a signed metering certificate.
[0059] S4. After receiving the signed metering certificate, the real-time matching metering chain calls the public key registered on the main settlement chain to verify the signature, and converts the electricity information in the verified certificate into an on-chain record, forming a trusted performance data stream.
[0060] S5. Analyze the reliable performance data stream from the dynamic settlement contract on the real-time matching metering chain, calculate the difference between the theoretically required performance volume and the actual performance volume, and generate a real-time performance deviation value;
[0061] S6. The dynamic settlement contract triggers the state transition of the performance position state machine based on whether the real-time performance deviation value exceeds the preset threshold, and generates economic incentives or penalties based on the transitioned state, and generates dynamic adjustment instructions.
[0062] S7. Execute dynamic adjustment instructions to guide users to adjust their energy behavior through real-time cost changes or revenue incentives to reduce performance deviations and form a closed-loop settlement cycle;
[0063] S8. After the settlement cycle of the fact-closed loop ends, the metering chain summarizes the performance results and economic adjustments in real time to generate a final net settlement list for transaction settlement on the main settlement chain.
[0064] In one embodiment of the present invention, step S1 includes the following steps:
[0065] Extract the public key corresponding to the hardware security module and submit it to the main settlement chain along with the user's wallet address for binding; after binding is completed, generate a digital identity that integrates the physical device fingerprint and the on-chain account.
[0066] Specifically, the process begins by establishing a trusted digital twin identity for the physical devices used to participate in virtual electric field transactions, implanting a unique and tamper-proof root of trust into the physical devices, and then forming a digital identity firmly bound to the physical devices in the digital domain.
[0067] A hardware security module with a built-in unique private key is physically integrated into the electricity metering device. The core function of this module is to generate and securely store the private key in an asymmetric encryption key pair. This private key cannot be read or exported externally. A dedicated interface program extracts the public key corresponding to the unique private key from the hardware security module. Subsequently, the user or system administrator, through a client application, packages this public key along with the user-specified wallet address into a registration transaction and sends it to the main settlement chain. The pre-set identity registration smart contract on the main settlement chain receives this transaction, verifies its legitimacy, and records the public key and wallet address as a key-value pair in on-chain storage, completing the association. Finally, the registered public key, combining the unique identifier of the physical device and the user's digital asset account, constitutes the obtained digital identity, which serves as the sole credential for all subsequent transactions and settlement processes.
[0068] In one embodiment of the present invention, the hardware security module is a dedicated chip with cryptographic computation and secure storage capabilities. It internally generates and stores a unique private key, which is inaccessible externally. This unique private key is unique binary data generated according to cryptographic security standards. Its data structure can be a 256-bit random number, used as the basis for digital signatures to prove the uniqueness and authenticity of the data source. Its generation is based on a true random number generator within the hardware security module, ensuring that each module's private key is different and unpredictable. Specifically, the hardware security module is a dedicated cryptographic chip with physical tamper-proof characteristics. The module integrates a true random number generator to generate unique private keys with sufficient cryptographic strength and employs a physical tamper-proof design to prevent unauthorized external access or export of the private key. The module supports standard asymmetric encryption algorithms, such as ECDSA, using secp256k1 or P-256 curves, and hash algorithms, such as SHA-256. The signature operation is completed independently within the module; external systems can only obtain the signature result and cannot access the original private key. For example, Microchip's ATECC608A or a similar chip can be used as the hardware security module. This module connects to the main controller of the energy metering device via an I2C or SPI bus. The communication protocol must be enabled with encryption and authentication mechanisms, such as TLS or similar secure channels, to prevent eavesdropping and replay attacks on the bus.
[0069] It's important to note that the public key is another string of binary data generated unidirectionally from the unique private key using algorithms such as elliptic curve cryptography. It's used to verify digital signatures generated by the corresponding private key. The main settlement chain is a blockchain network with security and data immutability. It serves as the foundation of trust, recording the binding relationship between public keys and wallet addresses, ensuring the authority and persistence of identity registration information. A wallet address is a unique identifier used by a user on the main settlement chain to receive, send, and manage digital assets. Its data structure is a string generated from the public key through operations such as hashing, for example, 40 hexadecimal characters starting with 0x.
[0070] The digital identity of a registered public key is a data structure recorded on the main settlement chain. It binds the public key of the hardware security module to the user's wallet address, thus serving as a unified and trusted identity credential for subsequent energy contracts to verify the authenticity of transaction participants and the reliability of metering data.
[0071] The pre-defined identity registration smart contract is a core contract deployed on the main settlement chain, responsible for managing and verifying the digital identity of physical devices.
[0072] For example, suppose generator unit 1 of a power plant is preparing to connect to a virtual power plant trading system. First, the aforementioned hardware security module is installed in the unit's outgoing meter. After power-on, the hardware security module generates a unique private key. Simultaneously, the hardware security module calculates the corresponding public key. The system administrator reads this public key using the accompanying software and submits it, along with the power plant's receiving wallet address, to the main settlement chain. After the identity registration contract on the main settlement chain is executed, the association between the public key and the wallet address is recorded, thus generating a digital identity representing the registered public key of generator unit 1. In subsequent transactions, any data issued by this meter and signed using this private key can be verified as originating from generator unit 1 of the power plant by querying the record associated with this public key on the main settlement chain, and the proceeds can be settled to its wallet address.
[0073] In one embodiment of the present invention, step S2 includes the following steps:
[0074] Upon receiving the contract creation instruction, the system locks the assets of both parties on the main settlement chain and records the total transaction volume, transaction duration, and digital identities of both parties. Based on the contract information, the system deploys a smart contract instance containing a performance position state machine on the real-time matching metering chain. The system sets the initial state of the performance position state machine to balance and configures the trigger threshold for the state to transition from balance to surplus or deficit, generating a dynamic settlement contract to be executed.
[0075] Specifically, after the physical devices of both trading parties complete identity binding, a contract system with real-time status tracking capabilities is generated based on their trading intentions. Upon receiving a transaction request jointly initiated by both parties, the system uses the digital identity of the generated registered public key to sign the request, ensuring its authenticity and non-repudiation. After verifying the validity of both parties' identities, the system first creates a basic energy contract on the main settlement chain. This contract locks the performance guarantee funds provided by both parties and records the core terms of the transaction, including the total transaction electricity volume, transaction duration, and the digital identity of both parties' registered public keys. Based on the contract information on the main settlement chain, the system automatically deploys a new smart contract instance on the faster real-time matching and metering chain. Within this new contract instance, a key component, the performance position state machine, is initialized. This state machine is designed to contain variables with three preset states: balanced, surplus, and deficit, with the initial state set to balanced. The triggering conditions for state transitions—that is, the triggering threshold for the specific electricity deviation from the balanced state to the surplus or deficit state—are also written into the contract. Generate a dynamic settlement contract that is ready to be executed, consisting of a static asset contract on the main settlement chain and a dynamic state contract on the real-time matching metering chain.
[0076] The real-time matching metering chain can employ a blockchain network based on proof-of-stake or delegated proof-of-stake consensus mechanisms to achieve high throughput and low latency. On-chain nodes are run by grid operators, transaction participants, or authorized third parties. Each node is equipped with a dedicated network interface and data processing unit for real-time reception, verification, and storage of metering credentials. The block generation interval is typically set to 1-5 seconds to ensure rapid on-chain uploading of metering data. Furthermore, the real-time matching metering chain interacts with the main settlement chain through cross-chain bridging protocols, such as atomic swaps based on hash time locks, ensuring data synchronization and asset transfer security. On-chain smart contracts can be written in languages such as Solidity or Rust and deployed on the chain's virtual machine, supporting high-frequency state updates and event triggering. In some embodiments, the real-time matching metering chain can be built on Hyperledger Fabric or a custom Substrate framework, where nodes communicate with electricity metering devices via gRPC or WebSocket interfaces to achieve real-time broadcasting and capture of metering credentials.
[0077] The performance position state machine is the core logic module within the smart contract deployed on the real-time matching and metering chain. It is used to track and mark the performance of contract participants in real time. This state machine is a data structure containing defined states and transition rules. In this embodiment, a balanced state indicates that the performance progress meets expectations, a surplus state indicates overperformance, and a deficit state indicates underperformance. The dynamic settlement contract to be executed consists of a parent contract on the main settlement chain responsible for funds and core terms, and a sub-contract on the real-time matching and metering chain responsible for real-time state tracking. It is used to prepare the entire transaction's settlement framework and dynamic adjustment mechanism before the performance period begins.
[0078] For example, suppose a power plant with a registered public key digital identity wants to sell 1000 kWh of electricity to charging station A, which also has a registered public key digital identity, and agrees to complete the transaction within the next 10 hours. After both parties jointly initiate the transaction request, the system creates an energy contract on the main settlement chain, such as locking 100 units of digital stablecoins from each party as a performance guarantee. Subsequently, the associated smart contract instance is initialized on the real-time matching metering chain, and the performance position state machine within the instance is created, with its initial state set to balanced. The contract also sets a trigger threshold for state transitions; for example, when the actual performance amount of either party deviates from the theoretical performance amount calculated over time by more than a trigger threshold of 50 kWh, the state of the performance position state machine will change. This complete contract system, including the main settlement chain asset locking and the real-time matching metering chain state machine configuration, is the dynamic settlement contract to be executed.
[0079] In one embodiment of the present invention, step S3 includes the following steps:
[0080] The hardware security module periodically or based on power change events collects raw metering data, including timestamps, cumulative power consumption, and current direction; packages the raw metering data into a standard format data packet; and calls the private key inside the hardware security module to digitally sign the data packet, generating a signed metering certificate.
[0081] Specifically, once the generated, pending dynamic settlement contract reaches its agreed performance time, the physical flow of electrical energy is transformed into verifiable digital credentials. First, the electricity metering devices installed at the physical locations of both trading parties begin operation. The hardware security modules integrated within these devices monitor the flow of electrical energy in real time. This monitoring can be periodic, such as collecting data every 5 seconds, or event-driven, such as triggering data collection when the cumulative electricity consumption changes. The collected raw metering data mainly includes three core elements: the current timestamp, the cumulative electricity consumption reading since the contract began, and current direction information indicating whether the electrical energy is input or output. This raw metering data is a set of physical quantities directly measured by the electricity metering devices, serving as the original information source for generating the credentials.
[0082] After the data collection is completed, the hardware security module will organize the raw measurement data into data packets according to a predefined standard format. The data packets are a collection of raw measurement data encapsulated according to a specific network protocol or application standard, which facilitates subsequent signing and network transmission.
[0083] It is worth noting that the hardware security module uses its internally stored private key, uniquely paired with the public key registered on the main settlement chain, to digitally sign the data packet. The digital signature is an encryption process that generates a unique string appended to the data packet. This string proves that the data packet was indeed generated by the specific hardware security module and guarantees that the data packet has not been tampered with during transmission. It is typically obtained by performing asymmetric encryption on the data packet using the unique private key, ensuring data integrity, authenticity of origin, and non-repudiation of the action. After the signing operation, the final output is a signed metering certificate containing a trusted timestamp, tamper-proof metering value, and proof of origin. This is a composite data structure, consisting of the original data packet and the digital signature appended to it. Its function is to serve as a trusted digital representation of the flow of electrical energy in the physical domain, providing a basis for subsequent on-chain verification and settlement.
[0084] For example, further illustrating the above example, once the contract performance period begins, generator unit 1 of the power plant will start supplying electricity to the grid, and charging station A will also be able to draw power from the grid. On the power plant side, suppose the hardware security module within its bound energy metering device collects a current cumulative output of 0.5 kWh at 10:00:05, with the current direction positive and representing output. The hardware security module packages this information and uses its internally stored unique private key to sign the data packet, generating a signed metering certificate. Because it has been signed with the private key, the data content of this certificate can be trusted; any attempt to modify the 0.5 kWh value will result in signature verification failure.
[0085] In one embodiment of the present invention, step S4 includes the following steps:
[0086] Nodes on the real-time matching metering chain capture signed metering certificates; they index the source of the metering certificates to the main settlement chain and obtain the corresponding public key; they use the public key to sign and verify the metering certificates, and write the verified metering data into the blocks of the real-time matching metering chain to form a trusted performance data stream.
[0087] Specifically, after the facts of electrical energy flow in the physical domain are encapsulated into signed metering certificates, the authenticity of these certificates is verified, and the confirmed physical facts are transformed into immutable on-chain records in the digital domain.
[0088] The network nodes on the real-time matching metering chain continuously listen for and receive signed metering certificates broadcast from various electricity metering devices. When a node captures a certificate, it first parses the certificate's information to determine which registered public key digital identity issued the certificate. Subsequently, the node sends a query request to the main settlement chain, retrieving the public key registered and bound to that identity.
[0089] After obtaining the public key, the node performs a crucial cryptographic verification operation, using this public key to verify the validity of the digital signature attached to the credential. This verification process ensures that the credential indeed originates from its claimed hardware security module and that the metering data within the credential has not been tampered with during transmission. Only credentials that pass signature verification are considered legitimate and trustworthy.
[0090] For verified credentials, nodes extract core electrical information such as power volume and current direction. This information, along with timestamps and source identity, is then packaged into transaction information and submitted and recorded in a new block of the real-time matching metering chain. This continuous process of receiving, verifying, and uploading to the chain creates a usable data stream composed of verified, chronologically ordered performance records—a trusted performance data stream. This stream is a continuous and immutable data record formed on the real-time matching metering chain. Its data structure is typically a sequence of multiple blockchains, with each block containing several verified performance records. This provides a reliable and unified data source for subsequent contract state updates, ensuring that all settlements are based on verified physical facts.
[0091] For example, a signed metering certificate generated by Unit 1 of a power plant is broadcast to the network. Assuming a node on the real-time matching metering chain receives this certificate, it identifies the signer and queries the main settlement chain for the record corresponding to the power plant's public key. If the main settlement chain confirms the public key's validity, the node then uses that key to verify the certificate's digital signature. If the verification is successful, the node confirms the certificate's authenticity and writes the output power information (0.5 kWh) into a new block on the real-time matching metering chain. As time progresses, more signed metering certificates from the power plant and charging station A are continuously received, verified, and recorded on the chain. These sequentially linked, immutable records on the real-time matching metering chain constitute a trusted performance data stream.
[0092] In one embodiment of the present invention, step S5 includes the following steps:
[0093] The actual delivered electricity volume is obtained by summing the completed power supply and electricity consumption of both parties in the transaction based on the trusted performance data stream; the theoretical delivery volume at the current time point is calculated based on the total transaction volume and total transaction duration; the actual delivered electricity volume is compared with the theoretical delivery volume to generate a real-time performance deviation value.
[0094] Specifically, after establishing a reliable performance data stream that includes the actual performance status in the physical domain, these discrete performance records are transformed into quantitative indicators that can reflect the contract performance status in real time through continuous calculation.
[0095] The calculation process is automatically executed by a dynamic settlement contract deployed on a real-time matching and metering chain. First, the dynamic settlement contract continuously reads each new record from the trusted performance data stream. For each record, the contract updates the performed electricity amount for both parties based on the electricity value and current direction information. For example, for the power generator, its performed electricity amount increases with each record representing electricity output; for the power consumer, its performed electricity amount increases with each record representing electricity input.
[0096] At the same time, the dynamic settlement contract also calculates the amount of electricity that should theoretically be delivered at the current point in time, based on the total transaction volume and total transaction duration set at the time the contract was signed. This theoretical value is usually calculated assuming that the electricity is delivered evenly throughout the entire transaction duration.
[0097] Finally, the dynamic settlement contract subtracts a party's actual fulfilled volume from its theoretically due volume at the same time. This difference is generated as that party's real-time performance deviation value. It should be understood that this deviation value is a dynamically changing value; a positive value represents overfulfillment, and a negative value represents underfulfillment.
[0098] Real-time performance deviation value The calculation formula is:
[0099]
[0100] Theoretically required electricity volume The calculation formula is:
[0101]
[0102] in, This represents the real-time performance deviation value, measured in kilowatt-hours. It directly quantifies the degree of lead or lag in performance, serving as the direct basis for triggering state machine transitions. The actual amount of electricity fulfilled is obtained by accumulating all valid electricity records in the trusted fulfillment data stream up to the current moment. This value is set based on the immutable measurement facts on the blockchain. The theoretically required electricity volume is the expected performance progress calculated based on the contract terms at the current moment. The total electricity traded is a constant that is determined when the energy contract is created, and its setting is based on the transaction requests of both parties. The elapsed time is the time span from the start of contract performance to the present moment. The total transaction duration is a constant determined when the energy contract is created, and its setting is based on the transaction requests from both parties.
[0103] Among them, the real-time performance deviation value is the key dynamic data generated in this step. It is a floating-point number with a positive or negative sign, and it will serve as the direct basis for triggering the subsequent contract position state machine migration.
[0104] For example, assuming the contract between the two parties is to trade 1000 kWh of electricity within 10 hours, in the first hour after the contract begins, the dynamic settlement contract summarizes the actual electricity volume fulfilled by the power plant based on the trusted performance data stream. The figure is 120 kWh. Simultaneously, the contract calculates the theoretical electricity volume that should be delivered at this moment. The value is 1000 × 1 / 10 = 100 kWh. Subsequently, the contract calculates the power plant's real-time performance deviation. The value is +20 kWh. For charging station A, assuming its actual electricity consumption recorded from the trusted fulfillment data stream within 1 hour is 95 kWh, and its theoretically fulfillable electricity consumption is also 100 kWh, then its corresponding real-time fulfillment deviation value is... The value is -5 kWh. These two values (+20 kWh and -5 kWh) are the real-time performance deviation values obtained by the two parties to the transaction.
[0105] In one embodiment of the present invention, step S6 includes the following steps:
[0106] If the real-time performance deviation value is positive and exceeds the surplus threshold, the performance position status will be switched from balanced to surplus; if the real-time performance deviation value is negative and exceeds the deficit threshold, the performance position status will be switched from balanced to deficit; dynamic adjustment instructions will be generated based on the migrated status; among which, dynamic adjustment instructions include transaction fee discounts, transaction fee increases, or transaction priority reductions.
[0107] Specifically, after calculating the real-time performance deviation value reflecting the performance of each party, the internal state of the contract is triggered based on the magnitude of the deviation value, and a dynamic adjustment instruction is generated accordingly. The entire execution process is completed by the dynamic settlement contract on the real-time matching metering chain. The dynamic settlement contract continuously compares the latest real-time performance deviation value of each party with the state transition trigger threshold set during contract initialization.
[0108] For example, suppose the contract is set to trigger a state transition when the absolute value of the real-time performance deviation exceeds 50 kilowatts. When the contract detects that a party's real-time performance deviation is positive and exceeds a preset surplus threshold, the contract will automatically update the corresponding performance position state machine variable from balanced to surplus. Conversely, if a negative real-time performance deviation is detected and its absolute value exceeds a deficit threshold, the contract will update that party's performance position state machine variable to deficit. These thresholds typically define the boundaries between a balanced state and a surplus or deficit state, and their setting can be based on a comprehensive consideration of historical performance data statistical analysis, real-time frequency stability requirements of the power grid, and the credit rating of the counterparty. In the contract, these thresholds are stored as immutable state variables, ensuring the transparency and consistency of settlement rules.
[0109] Once the state transitions, the contract generates new instructions according to preset logical rules. These rules are as follows: for users entering a surplus state, the generated instructions might reduce their subsequent transaction fees or grant them priority in selling surplus electricity in the spot market. For users entering a deficit state, the generated instructions might increase their transaction fees or reduce their priority in future transactions. These real-time generated instructions, designed to regulate through economic means, collectively constitute the dynamic adjustment instructions.
[0110] Dynamic adjustment instructions are a set of commands generated by the dynamic settlement contract and directly executable by other parts of the system. Their function is to influence user performance through immediate reward and penalty signals. For example, the instruction's data structure might be a JSON object containing the user's wallet address, adjustment type, and adjustment range. These dynamic adjustment instructions are set based on an economic incentive and constraint model pre-coded during contract design, designed to maintain power grid supply and demand balance and contract integrity.
[0111] For example, suppose the preset surplus and deficit thresholds in the dynamic settlement contract are both 50 kWh. The power plant's real-time performance deviation is +20 kWh, which does not reach the surplus threshold, so its performance position state machine remains in a balanced state. Charging station A's real-time performance deviation is -5 kWh, which also does not reach the deficit threshold, and its state also remains balanced. Suppose that in the second hour, charging station A's electricity consumption increases significantly, causing its cumulative real-time performance deviation to become -60 kWh. At this time, the dynamic settlement contract detects that -60 kWh exceeds the 50 kWh deficit threshold, and therefore transitions charging station A's performance position state machine from balanced to deficit. After the state transition, the contract generates a dynamic adjustment instruction for charging station A's wallet address according to preset rules, with the instruction content: transaction fee rate increased by 10%. This instruction will be adopted by the system to adjust the cost of all subsequent transactions of charging station A.
[0112] In one embodiment of the present invention, step S7 includes the following steps:
[0113] Apply dynamic adjustment commands to subsequent user operations on the real-time matching metering chain;
[0114] Based on the user's proactive adjustment behavior, reverse adjustment is made to correct the contract performance status, thus forming a settlement cycle with a factual closed loop.
[0115] Specifically, after the system generates dynamic adjustment instructions, these instructions are executed, and their resulting economic impact is used to guide the energy supply and demand behavior of the physical domain back to equilibrium.
[0116] When a user's performance position state machine enters an unbalanced state, i.e., a surplus or deficit, the system will apply dynamically adjusted instructions generated for that user to all relevant operations on its real-time matching and metering chain. Specifically, these instructions can be sent to the user's terminal APP or the backend energy management system via an application programming interface (API), presented to the user in the form of push notifications, pop-up alerts, or interface parameter updates. For example, if the instruction is to increase the transaction fee rate, the real-time electricity purchase price seen by the user on the trading platform APP will be directly increased; if the instruction is to reduce the transaction priority, the new transaction request will be placed at a lower position in the matching queue.
[0117] To avoid economic penalties or pursue additional economic gains, users are guided to proactively adjust their actual behavior in the physical domain. Electricity consumers in a deficit may increase their equipment load to consume more energy, while power generators in a surplus may reduce the output power of their generators to reduce performance deviations. Through this method of adjusting physical domain behavior in reverse using economic signals from the digital domain, user performance deviations gradually decrease, causing the system to automatically return to equilibrium. This complete feedback process—from the generation of deviations to economic adjustments, then to physical behavior correction, and finally to the reduction of deviations—constitutes the factual closed-loop settlement cycle. It should be understood that the factual closed-loop settlement cycle describes a complete adjustment cycle, representing the entire closed-loop process from the detection of performance deviations, through the generation and execution of dynamic adjustment instructions, successfully guiding the energy behavior of the physical domain to make corresponding adjustments, and ultimately restoring the performance state to equilibrium, enabling contracts to be stably fulfilled even without human intervention.
[0118] For example, after the system automatically executes a dynamic adjustment instruction to increase the transaction fee rate by 10% for charging station A, the operator of charging station A finds that the cost of temporarily purchasing electricity from the electricity spot market to meet the sudden increase in demand is rising. To avoid this economic penalty and to restore its performance status machine to a balanced state as soon as possible, the operator can adjust the charging station's operating strategy through its backend energy management system. For example, it can suspend the dormancy of charging piles in standby mode or immediately allocate charging permissions to vehicles waiting in line to activate more charging piles to work simultaneously. By increasing the number of vehicles charging at the same time, the overall power load of the charging station is increased at the system level. As its actual power consumption increases, the real-time performance deviation value calculated in subsequent cycles gradually recovers from -60 kWh to 0. This process, from the system automatically executing the economic penalty to guiding the charging station operator to actively increase the physical power load, and ultimately reducing the performance deviation, completes the de facto closed-loop settlement cycle.
[0119] In one embodiment of the present invention, step S8 includes the following steps:
[0120] Upon contract expiration, the dynamic settlement contract ceases to receive measurement vouchers; it packages key settlement results and performs hash calculations to generate a final net settlement list; the final net settlement list is sent to the main settlement chain, verified, and then funds are cleared, including the transfer, return, or penalty deduction of assets.
[0121] Specifically, after the contract completes its performance through one or more closed-loop settlement cycles, a final, lightweight summary of the entire contract's execution result is provided, triggering secure fund clearing. When the total transaction duration stipulated in the contract ends, the dynamic settlement contract deployed on the real-time matching metering chain will automatically stop receiving new metering vouchers and enter settlement mode. In this mode, the contract will solidify the final performance difference between the two parties, i.e., the difference between the total actual performed volume and the total contractually agreed volume. Simultaneously, the contract will also summarize the total duration of each party's performance in different position states throughout the entire performance period, such as balance, surplus, and deficit, as well as the total amount of economic rewards and penalties accumulated according to dynamic adjustment instructions.
[0122] Subsequently, the contract packages these key settlement results, including the final performance difference, the duration of each state, and the cumulative reward and penalty amounts, into a data structure. To ensure the integrity and immutability of this data structure, the contract also performs a hash operation to generate a unique fingerprint. This lightweight data package, containing all the core settlement information after hash calculation, is the final net settlement list. Finally, the real-time matching metering chain sends this final net settlement list to the main settlement chain via a cross-chain communication protocol. Upon receiving the list, the energy contract initially created on the main settlement chain first verifies the validity of its hash fingerprint. After successful verification, it executes the final transfer, return, or penalty operation on the previously locked performance guarantee funds for both parties based on the final performance results and reward and penalty amounts recorded in the list, thereby completing the entire transaction's fund settlement in an automated manner.
[0123] The final net settlement list is the key data object generated in this step. It is a lightweight data packet that has been solidified through hash operations. Its data structure typically includes fields such as the final performance difference, the duration of each state, the cumulative reward and penalty amount, and a hash value. It will serve as the sole credential for the real-time matching metering chain to report the final settlement results to the main settlement chain. Its lightweight nature reduces the storage and computational burden on the main settlement chain.
[0124] For example, suppose that after a 10-hour contract expires, the summary results show that the power plant ultimately supplied an excess of 15 kWh of electricity, while charging station A still has an 8 kWh performance deficit. The contract also records that charging station A remained in a deficit state for a total of 2.3 hours, during which a transaction fee increase equivalent to 5 units of digital stablecoins was executed. The contract packages the following information: {+15 kWh, -8 kWh, 2.3 hours of deficit duration, 5 units of stablecoin penalty} and performs a hash calculation to generate a final net settlement list. This list is sent to the main settlement chain. After the energy contract on the main settlement chain verifies the validity of the list, it begins to execute the liquidation. For example, 5 units are deducted from charging station A's 100 units of performance guarantee funds and given to the system as a penalty, and assets of corresponding value are deducted from the 8 kWh deficit and given to the power plant as compensation; then, the power plant's 100 units of performance guarantee funds are fully returned, and it is additionally paid the revenue from the excess supply of 15 kWh of electricity. At this point, the entire on-chain settlement of the transaction was completed automatically.
[0125] In one embodiment of the present invention, the real-time performance deviation value is further compared with a preset power grid stability contribution threshold; if the absolute value of the real-time performance deviation value is not greater than the power grid stability contribution threshold, a stability contribution identifier is generated; when generating a dynamic adjustment instruction, if the stability contribution identifier is detected, the economic penalty measures are reduced or the economic incentive measures are increased.
[0126] Specifically, a grid stability contribution mechanism was introduced to encourage small supply and demand fluctuations that are beneficial to grid stability. Real-time performance deviations are calculated in the dynamic settlement contract. Subsequently, instead of immediately comparing it with the surplus / deficit threshold that triggers position state transition, it is first compared with a preset, smaller grid stability contribution threshold. Compare them.
[0127] The power grid stability contribution threshold It is a positive number, and its setting is based on the small fluctuation range that the grid operator allows for frequency stability and power balance. For example, it can be set to the total traded electricity volume. 1% or a fixed value derived from historical data, such as 5 kilowatt-hours.
[0128] If the absolute value of one party's real-time performance deviation This indicates that although there are minor deviations in the user's performance, these deviations are within a flexible range that is harmless or even beneficial to the stable operation of the power grid. The dynamic settlement contract will generate a stability contribution identifier for this and link it to the user's account.
[0129] Subsequently, when generating the dynamic adjustment instruction in step S6, the dynamic settlement contract checks for the existence of a stable contribution identifier. If a user should receive an incentive due to a minor overperformance, for example... It is 3 kilowatt-hours, and If a user's contribution is 5 kilowatt-hours, but the deviation does not reach a larger surplus threshold and therefore cannot trigger a state transition, the system may grant a small bonus due to their stable contribution identifier. Conversely, if a user should face a penalty for minor underperformance, but their deviation is within the contribution threshold range, the system may exempt them from or significantly reduce the penalty based on their stable contribution identifier.
[0130] This mechanism ensures the seriousness of contract performance while encouraging minor supply and demand fluctuations that are beneficial to the overall stability of the power grid, thus achieving synergistic optimization between the individual interests of the contract and the public interests of the power grid.
[0131] See appendix Figure 2 The present invention also proposes an automated transaction settlement system for virtual electric fields using blockchain smart contracts, comprising the following modules:
[0132] The digital identity binding module is used to integrate the hardware security module into the electricity metering device. The hardware security module has a built-in unique private key and registers the association between the public key of the hardware security module and the user's wallet address on the main settlement chain to generate a digital identity.
[0133] The settlement contract generation module responds to transaction requests initiated based on digital identities, creates energy contracts on the main settlement chain, and initializes the performance position state machine on the real-time matching metering chain. The state machine includes balanced, surplus, and deficit states, and generates dynamic settlement contracts.
[0134] The certificate signature generation module, when the dynamic settlement contract enters the performance period, uses the hardware security module to call its internal private key to digitally sign the data packet containing the measurement value and generate a signed measurement certificate.
[0135] The certificate verification module is implemented by the real-time matching metering chain. After receiving the signed metering certificate, the real-time matching metering chain calls the public key registered on the main settlement chain to verify the signature and convert the electricity information in the verified certificate into an on-chain record, forming a trusted performance data stream.
[0136] The performance deviation calculation module analyzes the reliable performance data stream from the dynamic settlement contract on the real-time matching metering chain, calculates the difference between the theoretically required performance volume and the actual performance volume, and generates a real-time performance deviation value.
[0137] The state transition and instruction generation module is used to dynamically settle contracts by triggering state transitions of the performance position state machine based on whether the real-time performance deviation value exceeds a preset threshold, and generating economic incentives or penalties based on the transitioned state, and generating dynamic adjustment instructions.
[0138] The behavior closed-loop guidance module is used to execute dynamic adjustment instructions, guiding users to adjust their energy behavior to reduce performance deviations through real-time cost changes or benefit incentives, thus forming a de facto closed-loop settlement cycle.
[0139] The final net settlement module is used to match the performance results and economic adjustments of the metering chain in real time after the settlement cycle of the fact-closed loop ends, and generate a final net settlement list for transaction settlement on the main settlement chain.
[0140] Each of the modules can be implemented in whole or in part through software, hardware, or a combination thereof. It supports hardware embedded in or independent of the processor in the computer device, and also supports software stored in the memory of the computer device, so that the processor can call and execute the operations corresponding to each of the above modules.
[0141] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for automatic transaction settlement of virtual electric fields using blockchain smart contracts, characterized in that, Includes the following steps: S1. Integrate the hardware security module into the electricity metering device. The hardware security module has a built-in unique private key and registers the association between the public key corresponding to the hardware security module and the user's wallet address on the main settlement chain to generate a digital identity. S2. Respond to transaction requests initiated based on digital identities, create energy contracts on the main settlement chain, and initialize the performance position state machine on the real-time matching metering chain. The state machine includes balanced, surplus, and deficit states, and generates dynamic settlement contracts. S3. When the dynamic settlement contract enters the performance period, the hardware security module calls its internal private key to digitally sign the data packet containing the metering value and generate a signed metering certificate. S4. After receiving the signed metering certificate, the real-time matching metering chain calls the public key registered on the main settlement chain to verify the signature, and converts the electricity information in the verified certificate into an on-chain record, forming a trusted performance data stream. S5. Analyze the trusted performance data stream from the dynamic settlement contract on the real-time matching metering chain, calculate the difference between the theoretically due electricity volume and the actual due electricity volume, and generate a real-time performance deviation value. This includes the following steps: accumulate the completed power supply and power consumption of both parties in the transaction based on the trusted performance data stream to obtain the actual due electricity volume; calculate the theoretical due electricity volume at the current time point based on the total transaction electricity volume and total transaction duration; compare the actual due electricity volume with the theoretical due electricity volume to generate a real-time performance deviation value. S6. The dynamic settlement contract triggers a state transition of the performance position state machine based on whether the real-time performance deviation value exceeds a preset threshold, and generates economic incentives or penalties based on the transitioned state, generating dynamic adjustment instructions, including the following steps: if the real-time performance deviation value is positive and exceeds the surplus threshold, the performance position state is switched from balanced to surplus; if the real-time performance deviation value is negative and exceeds the deficit threshold, the performance position state is switched from balanced to deficit, and dynamic adjustment instructions are generated based on the transitioned state; wherein, the dynamic adjustment instructions include transaction fee discounts, transaction fee increases, or transaction priority reductions; S7. Execute dynamic adjustment instructions to guide users to adjust their energy behavior through real-time cost changes or revenue incentives to reduce performance deviations and form a closed-loop settlement cycle; S8. After the settlement cycle of the fact-closed loop ends, the metering chain summarizes the performance results and economic adjustments in real time to generate a final net settlement list for transaction settlement on the main settlement chain.
2. The method for automatic transaction settlement of virtual electric fields using blockchain smart contracts according to claim 1, characterized in that, Generating a digital identity includes the following steps: Extract the public key corresponding to the hardware security module and bind it to the user's wallet address to the main settlement chain; After the binding is completed, a digital identity is generated that combines the fingerprint of the physical device with the on-chain account.
3. The method for automatic transaction settlement of virtual electric fields using blockchain smart contracts according to claim 1, characterized in that, Generating a dynamic settlement contract includes the following steps: Receive contract creation instructions, lock the assets of both parties on the main settlement chain, and record the total transaction volume, transaction duration, and digital identities of both parties; Based on the contract information, deploy smart contract instances containing fulfillment position state machines on the real-time matching metering chain; The initial state of the performance position state machine is set to balance, and the trigger threshold for the state to transition from balance to surplus or deficit is configured to generate a dynamic settlement contract to be executed.
4. The method for automatic transaction settlement of virtual electric fields using blockchain smart contracts according to claim 1, characterized in that, Generating a signed measurement certificate includes the following steps: The hardware security module periodically or based on power change events collects raw metering data, including timestamps, cumulative power consumption, and current direction. Pack the raw measurement data into a standard format data package; The private key inside the hardware security module is used to digitally sign the data packet, generating a signed metering certificate.
5. The method for automatic transaction settlement of virtual electric fields using blockchain smart contracts according to claim 1, characterized in that, To form a trusted data flow for fulfillment, the following steps are included: Nodes in the real-time matching metering chain capture signed metering credentials. Retrieve the corresponding public key from the main settlement chain based on the source index of the metering certificate; The metering certificate is signed and verified using a public key, and the verified metering data is written into the block of the real-time matching metering chain to form a trusted performance data stream.
6. The method for automatic transaction settlement of virtual electric fields using blockchain smart contracts according to claim 1, characterized in that, A settlement cycle that forms a closed loop includes the following steps: Apply dynamic adjustment commands to subsequent user operations on the real-time matching metering chain; Based on the user's proactive adjustment behavior, reverse adjustment is made to correct the contract performance status, thus forming a settlement cycle with a factual closed loop.
7. The method for automatic transaction settlement of virtual electric fields using blockchain smart contracts according to claim 1, characterized in that, The process of clearing funds includes the following steps: Upon contract expiration, the dynamic settlement contract ceases to receive measurement vouchers; Key settlement results are packaged and hashed to generate the final net settlement list; The final net settlement list is sent to the main settlement chain for verification and fund clearing. Fund clearing includes the transfer, return or penalty of assets.
8. The method for automatic transaction settlement of virtual electric fields using blockchain smart contracts according to claim 1, characterized in that, It also includes the following steps: The real-time performance deviation value is compared with the preset power grid stability contribution threshold. If the absolute value of the real-time performance deviation is not greater than the power grid stability contribution threshold, a stability contribution identifier is generated. When generating dynamic adjustment instructions, if a stable contribution indicator is detected, economic penalties will be reduced or economic incentives will be increased.