Block chain-based energy transaction method and device, electronic equipment and storage medium
By using a blockchain-based energy trading method, the preference parameters and trading volumes of suppliers and demanders are obtained, and matching optimization calculations are performed to generate smart contracts. This solves the problems of lack of trust and transparency in traditional centralized energy management models, difficulties in system coordination and optimization, centralized operation and security risks, and low user participation. It realizes decentralized, automated, transparent and trustworthy energy trading, and improves user satisfaction and trading efficiency.
Patent Information
- Application Number
- CN202511756515.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-02-27
AI Technical Summary
Traditional centralized energy management models are ill-suited to the needs of decentralized peer-to-peer transactions, resulting in issues such as a lack of trust and transparency in transactions, difficulties in system coordination and optimization, centralized operation and security risks, and low user participation.
By adopting a blockchain-based energy trading method, the system obtains the preference parameters and transaction volumes of energy suppliers and demanders, performs matching and optimization calculations, generates smart contracts, and deploys them on the blockchain to achieve decentralized, automated, transparent, and trustworthy energy trading.
This has resulted in more rational energy allocation, improved user satisfaction, reduced transaction cycles, increased transaction efficiency and security, and enhanced user trust.
Smart Images

Figure CN121581998A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of energy trading management technology, and in particular relates to a blockchain-based energy trading method, device, electronic device and storage medium. Background Technology
[0002] With the widespread adoption of distributed renewable energy in local energy communities, traditional centralized energy management models are ill-suited to the demands of decentralized peer-to-peer transactions. Traditional centralized energy management models suffer from the following problems: transactions lack credible third-party notarization, data is easily tampered with, and trust costs are high; they cannot achieve collaborative optimization of energy devices within the community, leading to uneven energy distribution and low user satisfaction; and centralized operating platforms become single points of failure, posing risks such as data monopoly. Summary of the Invention
[0003] This application provides a blockchain-based energy trading method, apparatus, electronic device, and storage medium. Through blockchain-based energy trading, decentralized, automated, transparent, and trustworthy energy transactions can be achieved. By performing matching and optimization calculations based on a first preference parameter, energy supply, a second preference parameter, and energy demand, energy allocation can be made more reasonable and personalized user needs can be met, thereby improving user satisfaction.
[0004] In a first aspect, embodiments of this application provide a blockchain-based energy trading method, including: The energy supply of the energy supplier during a preset time period, the first preference parameter of the energy supplier, the energy demand of the energy demander during the preset time period, and the second preference parameter of the energy demander are obtained. Based on the first preference parameter, the energy supply, the second preference parameter, and the energy demand, a matching optimization calculation is performed to obtain the transaction parameters between each energy supplier and the matched energy demander. A smart contract is generated based on the transaction parameters, and the smart contract is deployed to the blockchain to conduct energy transactions between various energy suppliers and matching energy demanders based on the transaction parameters in the smart contract.
[0005] In some embodiments, the matching optimization calculation based on the first preference parameter, the energy supply, the second preference parameter, and the energy demand to obtain the transaction parameters between each energy supplier and the matched energy demander includes: The first preference parameter, the energy supply, the second preference parameter, and the energy demand are input into the matching optimization model to obtain the transaction parameters between each energy supplier and the matched energy demander. The matching optimization model includes a calculation relationship between minimizing the total transaction amount and maximizing the total preference matching reward. The constraints of the matching optimization model include at least one of the following: an upper limit constraint on the energy supply of the energy supplier, an upper limit constraint on the energy demand of the energy demander, a price preference constraint, and a default communication address constraint.
[0006] In some embodiments, the first preference parameter includes: supply price preference and energy type, the second preference parameter includes: demand price preference and energy preference type, and the preference matching reward is equal to the price matching reward multiplied by the price matching reward plus the type matching reward multiplied by the type matching weight, wherein the price matching reward is calculated based on the supply price preference and demand price preference, and the type matching reward is calculated based on the matching degree between energy type and energy preference type.
[0007] In some embodiments, the price matching reward is 1 if the supply price preference is less than or equal to the reference price and the reference price is less than or equal to the highest price of the demand price preference; otherwise, the price matching reward is 0. The type matching reward is 1 if the energy type and energy preference type match, and 0 if the energy type and energy preference type do not match.
[0008] In some embodiments, the method further includes: The actual energy transaction volume is obtained when an energy transaction is completed between the target energy supplier and the matching target energy demander. The transaction amount is calculated based on the actual energy trading volume and the transaction price in the smart contract. The transaction amount is transferred from the account of the target energy demander to the account of the target energy supplier.
[0009] In some embodiments, the method further includes: Get transaction records; The transaction records are confirmed using a consensus mechanism. After the transaction record is confirmed, the transaction record is encrypted and recorded in the blockchain.
[0010] In some embodiments, obtaining the energy supply amount of the energy supplier within a preset time period, the first preference parameter of the energy supplier, the energy demand amount of the energy demander within the preset time period, and the second preference parameter of the energy demander includes: Acquire historical power generation data from energy suppliers, weather data within the preset time period, and time characteristic information; The historical power generation data, the weather data, and the time characteristic information are input into the first prediction model to obtain the energy supply from the energy supplier during the preset time period, and / or, Acquire historical electricity consumption data of the energy demander, weather data within the preset time period, and time characteristic information; The historical electricity consumption data, the weather data, and the time characteristic information are input into the second prediction model to obtain the energy demand of the energy demander during the preset time period.
[0011] Secondly, embodiments of this application provide a blockchain-based energy trading device, comprising: The first acquisition module is used to acquire the energy supply of the energy supplier in a preset time period, the first preference parameter of the energy supplier, the energy demand of the energy demander in the preset time period, and the second preference parameter of the energy demander. The matching calculation module is used to perform matching optimization calculations based on the first preference parameter, the energy supply, the second preference parameter, and the energy demand to obtain the transaction parameters between each energy supplier and the matched energy demander. The transaction module is used to generate smart contracts based on the transaction parameters and deploy the smart contracts to the blockchain to conduct energy transactions between various energy suppliers and matching energy demanders based on the transaction parameters in the smart contracts.
[0012] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in any of the above-mentioned embodiments.
[0013] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in any of the preceding claims.
[0014] Fifthly, embodiments of this application provide a computer program product that, when run on a terminal device, causes the electronic device to execute any of the methods described above.
[0015] The beneficial effects of the embodiments in this application compared with the prior art are: This application provides a blockchain-based energy trading method. It obtains the energy supply of an energy supplier within a preset time period, the energy supplier's first preference parameter, the energy demand of an energy demander within the preset time period, and the energy demander's second preference parameter. Based on the first preference parameter, the energy supply, the second preference parameter, and the energy demand, it performs matching optimization calculations to obtain transaction parameters between each energy supplier and the matched energy demander. A smart contract is generated based on these transaction parameters and deployed to the blockchain to conduct energy transactions between each energy supplier and the matched energy demander based on the transaction parameters in the smart contract. This blockchain-based energy trading method enables decentralized, automated, transparent, and reliable energy transactions. By performing matching optimization calculations based on the first preference parameter, energy supply, second preference parameter, and energy demand, it makes energy allocation more rational, meets personalized user needs, and improves user satisfaction. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A schematic diagram of the structure of a centralized energy management system provided in related technologies; Figure 2 A schematic diagram illustrating the implementation process of a blockchain-based energy trading method provided for the implementation of this application; Figure 3 An interactive schematic diagram of a blockchain-based energy trading method provided in an embodiment of this application; Figure 4 A schematic diagram of the structure of a blockchain-based energy trading device provided in this application embodiment; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0018] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0019] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0020] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0021] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrases "if determined" or "if detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once detected," or "in response to detection."
[0022] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0023] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized.
[0024] Before introducing the embodiments of this application, a brief introduction to related technologies will be given: With the increasing prevalence of distributed renewable energy sources (such as rooftop solar and small-scale wind power) in local energy communities, traditional centralized energy management models are struggling to adapt to the demands of decentralized peer-to-peer trading, primarily due to the following technical issues: 1. Lack of trust and transparency in transactions: Figure 1 This is a schematic diagram of the structure of a centralized energy management system provided in related technologies, such as... Figure 1 As shown, existing direct energy transactions between members within a community lack a credible and neutral third party for recording and notarization. Transaction data is controlled by one party (such as a centralized platform), which poses a risk of tampering, concealment, or loss, leading to frequent disputes during transaction settlement and high trust costs.
[0025] 2. Challenges in System Coordination and Optimization: Renewable energy generation is intermittent and uncertain, and user electricity demand fluctuates in real time. Existing technologies lack high-precision forecasting and automated scheduling capabilities, making it impossible to achieve coordinated and optimized operation of distributed power sources, energy storage devices, and flexible loads within a community. This often leads to uneven energy distribution within the community, resulting in excess energy waste or the inability to purchase electricity from the external grid at high prices.
[0026] 3. Centralized Operations and Security Risks: Existing solutions often rely on a centralized operating platform as the core hub. This platform becomes a single point of failure; if attacked or malfunctioning, the entire system will be paralyzed. Furthermore, the platform operator possesses control over all users' privacy data and transactions, posing risks of data monopoly, privacy breaches, and abuse of power.
[0027] 4. Low user participation: Due to the lack of transparency in trading rules and the complexity of the process, users are unable to flexibly participate in the market according to their own personalized preferences (such as prioritizing the use of green energy, setting expected electricity price ranges, and participating in demand response), which reduces their initiative and enthusiasm for participating in community energy sharing.
[0028] Centralized energy management platforms suffer from single points of failure and trust dependency issues; fixed electricity prices or simple bilateral agreements lack flexibility and fail to reflect the real-time value of energy; and traditional databases for recording transactions lack transparency and tamper resistance.
[0029] To address the above problems, the following methods are commonly used in related technologies, but all of them have significant drawbacks: 1. Centralized Energy Management Platforms: These platforms are operated by utility companies or third-party service providers, responsible for aggregating information, centralizing scheduling, and handling financial settlements. However, this approach reinforces reliance on centralization and fails to address fundamental issues such as single points of failure, data monopolies, and privacy breaches. Users lack autonomy, and the platform's reliability and fairness depend entirely on the operator's credibility.
[0030] 2. Fixed internal electricity price or simple bilateral agreement: A uniform internal electricity price is set within the community, or members are allowed to negotiate prices simply. However, this static pricing mechanism cannot reflect the real-time value of energy and the supply and demand relationship, resulting in extremely poor flexibility. It fails to incentivize users to generate more electricity during peak power generation periods or to proactively conserve energy during peak power consumption periods, leading to low system optimization efficiency.
[0031] 3. Traditional centralized database transaction recording: This method uses a centralized database system to record transaction flows. However, these records are easily tampered with by insiders or hackers, resulting in poor transparency and traceability. In the event of a dispute, it is difficult to provide universally accepted and immutable evidence, making auditing challenging.
[0032] In view of the problems in related technologies, this application provides a blockchain-based energy trading method. This blockchain-based energy trading method can be applied to electronic devices, such as mobile phones, tablets, energy devices, and computers. The electronic device can be any node in the blockchain. Figure 2 A schematic diagram illustrating the implementation process of a blockchain-based energy trading method provided for the purposes of this application is shown below. Figure 2 As shown, it includes: Step S101: Obtain the energy supply amount of the energy supplier within a preset time period, the first preference parameter of the energy supplier, the energy demand amount of the energy demander within the preset time period, and the second preference parameter of the energy demander.
[0033] In this embodiment, blockchain is a distributed ledger technology, where multiple nodes jointly maintain a continuously growing chain-like data structure. Each data block contains transaction information within a certain time period and is linked to the previous data block through cryptographic methods, forming an immutable chain. Blockchain features decentralization, immutability, and transparency, ensuring the security, reliability, and traceability of transaction information in energy transactions. An energy supplier refers to an entity capable of providing energy (such as electricity or natural gas), which can be a power plant, a distributed energy producer (such as a solar photovoltaic panel owner), etc. The energy supplier can be referred to as a seller. The preset time period is a pre-defined time range used to statistically analyze energy supply and demand. This time period can be flexibly set according to actual needs, such as one hour, one day, or one week. Energy supply refers to the total amount of energy that the energy supplier can provide within the preset time period, with the unit depending on the energy type; for example, electricity is commonly supplied in kilowatt-hours (kWh), and natural gas in cubic meters (m³). The first preference parameter reflects a set of parameters indicating various preferences of energy suppliers in energy transactions. These preferences may include price preferences (the desired price for energy sales), transaction time preferences (the desired time period for transactions), and transaction counterparty preferences (a preference for trading with specific types or sizes of energy consumers). Energy consumers are entities that have energy needs and require to purchase energy from energy suppliers; these can be industrial enterprises, commercial buildings, residential users, etc., and can be referred to as buyers. Energy demand is the total amount of energy that the energy consumer needs to purchase within a preset time period, with units corresponding to energy supply. The second preference parameter reflects a set of parameters indicating the energy consumer's preferences in energy transactions, such as price affordability (the highest price they are willing to pay), energy quality requirements (requirements regarding energy purity, stability, etc.), transaction flexibility requirements (whether multiple transactions are allowed, etc.), and transaction type.
[0034] In this embodiment of the application, historical power generation data of the energy supplier, weather data and time characteristic information within the preset time period can be obtained; the historical power generation data, weather data and time characteristic information are input into a first prediction model to obtain the energy supply of the energy supplier within the preset time period, and / or, historical electricity consumption data of the energy demander, weather data and time characteristic information within the preset time period can be obtained; the historical electricity consumption data, weather data and time characteristic information are input into a second prediction model to obtain the energy demand of the energy demander within the preset time period.
[0035] In this embodiment, energy suppliers and consumers can submit their preference parameters to the platform through online questionnaires, system interface settings, etc., thereby obtaining first preference parameters and second preference parameters.
[0036] Step S102: Based on the first preference parameter, the energy supply, the second preference parameter, and the energy demand, a matching optimization calculation is performed to obtain the transaction parameters between each energy supplier and the matched energy demander.
[0037] In this embodiment, matching optimization calculation is a mathematical calculation method aimed at finding the optimal matching scheme based on various parameters (supply, demand, preference parameters, etc.) of energy suppliers and demanders, so as to maximize the overall benefits of energy transactions while satisfying the needs and preferences of both parties. Algorithms for matching optimization calculation may include linear programming, integer programming, multi-objective optimization algorithms, etc.
[0038] In this embodiment, a mathematical model containing multiple variables and constraints can be established based on the characteristics and objectives of energy trading. For example, the objective function can be to minimize total transaction costs, achieve energy supply and demand balance, and satisfy the preferences of both parties, while constraints can include energy supply, demand, price range, and trading time. A suitable optimization algorithm is selected to solve the problem based on the characteristics of the mathematical model. For simple linear problems, linear programming algorithms can be used; for problems involving integer variables, integer programming algorithms may be necessary; and for problems with multiple conflicting objectives, multi-objective optimization algorithms, such as genetic algorithms or particle swarm optimization algorithms, can be employed.
[0039] In this embodiment of the application, the collected data such as energy supply, demand and preference parameters can be input into a mathematical model, and the selected optimization algorithm can be used to calculate and obtain the optimal solution that satisfies various constraints, that is, the transaction parameters between each energy supplier and the matched energy demander.
[0040] Step S103: Generate a smart contract based on the transaction parameters and deploy the smart contract to the blockchain to conduct energy transactions between various energy suppliers and matched energy demanders based on the transaction parameters in the smart contract.
[0041] In this embodiment, the transaction parameters are determined after matching and optimization calculations, and are used to describe the specific transaction details between the energy supplier and the matched energy demander. Transaction parameters include transaction price, transaction quantity, and transaction time. A smart contract is an automatically executing computer program deployed on the blockchain that automatically processes transactions according to preset rules and conditions. In energy trading, smart contracts can ensure that transactions are automatically executed according to pre-agreed transaction parameters without third-party intervention, improving transaction efficiency and credibility.
[0042] In this embodiment, smart contract code can be written using a smart contract programming language based on the calculated transaction parameters. The smart contract code explicitly specifies the identities of both parties, the transaction price, the transaction quantity, the transaction time, and default handling terms. The written smart contract code is deployed to the blockchain network using a blockchain client tool or development platform. During deployment, the smart contract is compiled into bytecode and stored at a specific address on the blockchain, simultaneously generating a corresponding contract account. When the preset transaction time is reached or other triggering conditions are met, the smart contract automatically executes the transaction operation. For example, it might deduct the corresponding fees from the energy demander's account and transfer the energy supplier's due revenue to their account, while simultaneously recording the transaction information in the blockchain ledger to ensure transparency and traceability.
[0043] This application provides a blockchain-based energy trading method. It obtains the energy supply of an energy supplier within a preset time period, the energy supplier's first preference parameter, the energy demand of an energy demander within the preset time period, and the energy demander's second preference parameter. Based on the first preference parameter, the energy supply, the second preference parameter, and the energy demand, it performs matching optimization calculations to obtain transaction parameters between each energy supplier and the matched energy demander. A smart contract is generated based on these transaction parameters and deployed to the blockchain to conduct energy transactions between each energy supplier and the matched energy demander based on the transaction parameters in the smart contract. This blockchain-based energy trading method enables decentralized, automated, transparent, and reliable energy transactions. By performing matching optimization calculations based on the first preference parameter, energy supply, second preference parameter, and energy demand, it makes energy allocation more rational, meets personalized user needs, and improves user satisfaction.
[0044] The method provided in this application, through automated matching optimization calculations and smart contract execution, reduces manual intervention and cumbersome negotiation processes, significantly shortening the transaction cycle. Energy suppliers and demanders do not need to spend a lot of time and energy on one-on-one negotiations and signing contracts; transactions can be completed in a short time, improving the liquidity of the energy market. The decentralized and tamper-proof characteristics of blockchain ensure the authenticity and integrity of transaction information. The automatic execution mechanism of smart contracts guarantees that transactions are carried out accurately and without error according to preset rules, enhancing the trust between the transacting parties. Considering the preference parameters of energy suppliers and demanders, it can better meet the personalized transaction needs of both parties. Energy suppliers can choose suitable trading partners and trading conditions according to their preferences, and energy demanders can obtain energy products and services that better meet their needs, improving the satisfaction of both parties.
[0045] In some embodiments, step S102 can be implemented by the following steps: The first preference parameter, the energy supply, the second preference parameter, and the energy demand are input into the matching optimization model to obtain the transaction parameters between each energy supplier and the matched energy demander. The matching optimization model includes a calculation relationship between minimizing the total transaction amount and maximizing the total preference matching reward. The constraints of the matching optimization model include at least one of the following: an upper limit constraint on the energy supply of the energy supplier, an upper limit constraint on the energy demand of the energy demander, a price preference constraint, and a default communication address constraint.
[0046] In this embodiment, the matching optimization model is a mathematical model for solving the matching problem between energy suppliers and demanders. It comprehensively considers multiple factors, sets an objective function and constraints, and uses a specific algorithm to find the optimal matching scheme to determine the transaction parameters between the two parties. The total transaction amount is the total cost involved in completing energy transactions between all energy suppliers and matched energy demanders, determined by both the transaction price and the transaction quantity. The total preference matching reward is a reward indicator set to encourage better matching of the preferences of energy suppliers and demanders. When the preferences of both parties are well satisfied in the transaction, this reward will provide a certain positive incentive, which may be reflected in the model as a weighted value or a specific calculation term to optimize the matching results. The upper limit constraint on energy supply specifies the maximum amount of energy that the energy supplier can provide within a preset period, ensuring that the supplier does not exceed its supply commitments. The upper limit constraint on energy demand limits the maximum amount of energy that the energy demander needs to purchase within a preset period, preventing the demander from making unreasonable and excessive demands. Price preference constraints are restrictions set on energy transaction prices, determined based on price preference parameters of energy suppliers and demanders, ensuring that transaction prices remain within an acceptable range for both parties. Default communication address constraints are default rules or restrictions set for communication addresses in data transmission or communication links involved in energy transactions to ensure accurate information delivery. For example, specifying the use of a default communication address for transaction information exchange under certain circumstances.
[0047] In this embodiment of the application, the first preference parameter includes: supply price preference and energy type, the second preference parameter includes: demand price preference and energy preference type, and the preference matching reward is equal to the price matching reward multiplied by the price matching reward plus the type matching reward multiplied by the type matching weight. The price matching reward is calculated based on the supply price preference and demand price preference, and the type matching reward is calculated based on the matching degree between the energy type and the energy preference type.
[0048] The following uses electricity trading as an example to illustrate this. The input to the matching optimization model can be represented by the following table:
[0049] In this embodiment, the objective function of the matching optimization model has two main objectives: first, to minimize the total transaction amount, that is, to minimize the total cost in the entire transaction process by reasonably matching energy suppliers and demanders; second, to maximize the total preference matching reward, which measures the preference matching situation and maximizes it through a certain calculation method (such as quantifying and weighting the matching degree of the preferences of both parties).
[0050] The objective function can be expressed as: ;in, This is the total transaction amount at the reference price; the goal is to find the transaction combination that minimizes this value. It is a preference matching reward term (as a negative term of the minimization objective, it actually maximizes the reward).
[0051] Preference matching reward items The calculation method is as follows: ; in, Reward weights are assigned to match the price. This is an indicator function. If the price preferences of buyers and sellers are compatible (i.e., the seller's lowest price)... Reference price The highest bid from the buyer is then... Otherwise . Reward weights for matching green electricity . If the buyer has a preference for green electricity And the seller provides green electricity. Those who qualify will receive higher rewards and be prioritized in the matchmaking process.
[0052] The formula states that: when the supply price preference is less than or equal to the reference price, and the reference price is less than or equal to the highest price of the demand price preference, the price matching reward is 1; otherwise, the price matching reward is 0. When the energy type and energy preference type match, the type matching reward is 1; when the energy type and energy preference type do not match, the type matching reward is 0.
[0053] Constraints may include: Upper limit constraints on energy supply: Any time window Inside, the seller The total electricity sold cannot exceed its energy supply, which can be expressed by the following formula: ; The upper limit constraint on the energy demand of energy demanders: Any time window Inside, the buyer The total electricity purchased cannot exceed its projected energy demand, which can be expressed by the following formula: ; Price preference constraint: Any matched transactions The price preferences of both buyers and sellers must be satisfied. This is typically guaranteed by rules outside the optimization model, or by setting an extremely high penalty term. It can be expressed by simplifying the objective function and limiting variables: if This is the final price of the contract, which must be within the acceptable range for both the buyer and seller. It can be expressed by the following formula: ; If this condition is not met, then Must be constrained as .
[0054] Communication address default value constraints: When deploying smart contracts, it is essential to ensure that: if transactions... If selected, the generated smart contract terms (transaction details) will include the final negotiated transaction price. and transaction volume .
[0055] In practice, transaction parameters can be output as a matrix. The smart contract generator converts this matrix into specific terms and ensures that system settings such as communication addresses are correctly incorporated into the final deployment configuration.
[0056] The method provided in this application minimizes the total transaction amount, prompting the model to find the lowest-cost transaction scheme, which helps reduce the overall cost of energy transactions and improve the economic efficiency of the energy market. Simultaneously, maximizing the total preference matching reward encourages better matching of preferences between the two parties, enabling transactions to not only meet basic supply and demand relationships but also satisfy the personalized needs of both parties at a higher level, further enhancing transaction efficiency. Upper limits on energy supply and demand ensure that energy supply and demand are matched within a reasonable range, avoiding insufficient supply or excessive demand, improving the stability and reliability of the energy market, and guaranteeing the rational allocation and effective utilization of energy. Price preference constraints keep transaction prices within an acceptable range for both parties, ensuring fairness and reducing the risk of transaction failure due to price disputes. Default communication address constraints ensure accurate and timely transmission of transaction information, improving transaction feasibility and efficiency, and avoiding transaction delays or errors caused by communication problems. By comprehensively considering various preference parameters and constraints, the matching optimization model can adapt to the transaction needs of energy suppliers and demanders of different types and sizes, improving the flexibility of the energy market. Whether it's bulk transactions by large energy companies or sporadic transactions between small distributed energy producers and individual users, the model can find suitable matching solutions, promoting the diversified development of the energy market.
[0057] In some embodiments, after step S103, the method further includes: Step S104: If an energy transaction is completed between the target energy supplier and the matched target energy demander, the actual energy transaction volume is obtained.
[0058] In this embodiment, the target energy supplier is the party ultimately determined to provide energy to a specific energy demander after matching and optimization processes in energy transactions. This supplier possesses the capability to provide the corresponding energy, meeting the demander's requirements in terms of energy type and supply quantity, and is selected to participate in the transaction within this scenario. The matched target energy demander is the energy demander that forms a corresponding transaction relationship with the target energy supplier through a series of matching rules and algorithms. This demander has an actual need for energy, and its demand characteristics (such as energy type, demand quantity, and acceptable price range) match the supply characteristics of the target energy supplier. The actual energy transaction volume is the amount of energy truly transferred during the actual energy transaction process between the target energy supplier and the matched target energy demander.
[0059] In this embodiment of the application, corresponding data acquisition devices, such as flow meters, electricity meters, and gas meters, are installed at each stage of energy transmission and trading. These devices can measure data such as energy flow or electricity in real time and accurately, thereby obtaining the actual amount of energy traded.
[0060] Step S105: Calculate the transaction amount based on the actual energy trading volume and the transaction price in the smart contract.
[0061] In this embodiment of the application, the transaction amount is a price standard that is pre-set in the smart contract and used when the target energy supplier and the target energy demander conduct energy transactions. This price may be determined based on various factors such as market conditions, negotiation between the two parties, and cost additions, and is clearly recorded in the smart contract as an important basis for calculating the transaction amount.
[0062] In this embodiment, the smart contract corresponding to the transaction can be read from the blockchain to obtain the pre-set transaction price information. The distributed ledger characteristic of the blockchain ensures the immutability and transparency of the smart contract data, guaranteeing the accuracy and reliability of the read price data. Based on the obtained actual energy transaction volume and transaction price, the transaction amount of the energy transaction is calculated using a simple multiplication formula (transaction amount = actual energy transaction volume × transaction price). The calculation process is completed automatically, reducing human intervention and improving calculation efficiency and accuracy.
[0063] Step S106: Transfer the transaction amount from the target energy demander's account to the target energy supplier's account.
[0064] In this embodiment, the accounts are separate accounts opened in the energy trading system for the target energy supplier and the target energy demander for fund management. These accounts are associated with real-world bank accounts or other payment accounts and are used to record the flow of transaction funds, including deposits, transfers, and expenditures.
[0065] In this embodiment, the accounts of the target energy demander and the target energy supplier can be verified to ensure the validity, legality, and sufficient funds in the accounts. Simultaneously, authorization information from both parties is obtained to confirm their agreement to the fund transfer, which can be achieved through technologies such as digital signatures and identity authentication. After account verification and authorization are completed, a fund transfer instruction is initiated through an interface with a bank or other payment institution. Funds are deducted from the target energy demander's account and transferred to the target energy supplier's account according to the calculated transaction amount. The entire transfer process is conducted in a secure network environment, employing encryption technology to protect the security of fund information. After the fund transfer is completed, the account information and transaction records of both parties are updated. Detailed transaction information, including transaction amount, transaction time, and transaction counterparty, is recorded in both parties' accounts for easy querying and verification. Simultaneously, the transaction record is stored on the blockchain to ensure the immutability and traceability of transaction information.
[0066] The method provided in this application, by accurately acquiring the actual energy transaction volume and calculating the transaction amount based on the transaction price specified in the smart contract, ensures that the calculation of the transaction amount is based on real and accurate transaction data, avoiding transaction disputes caused by human estimation or inaccurate data, and guaranteeing the fairness and accuracy of the transaction. The entire process of transaction amount calculation and fund transfer is automatically completed by the energy trading system without human intervention, greatly improving transaction efficiency. It reduces errors and delays that may be caused by manual operation, enabling energy transactions to be carried out quickly and smoothly, adapting to the rapidly changing needs of the energy market. The smart contract and account management system using blockchain technology ensures the immutability of transaction rules and the security and reliability of fund transfers. Both parties can trust the trading system to accurately execute transactions according to preset rules, without worrying about fraud, default, or other issues during the transaction process, enhancing trust among participants in the energy trading market and contributing to the healthy development of the energy market. Detailed transaction records and fund flow information are stored in the database and blockchain of the energy trading system, facilitating querying and verification by both parties and enabling regulatory authorities to monitor and manage energy transactions in real time. Regulatory authorities can analyze transaction data to promptly detect abnormal transaction behavior and maintain the normal order of the energy market.
[0067] In some embodiments, after step S106, the method further includes: Step S107: Obtain transaction records.
[0068] In this embodiment of the application, the transaction record is a detailed record of transaction-related information in energy trading or other types of trading activities. It covers various aspects such as the identity information of the trading parties (such as account, name, etc.), the specific content of the transaction (such as energy type, transaction quantity, transaction price, etc.), transaction time, transaction status (such as completed, in progress, cancelled, etc.), and is an important evidence reflecting the entire process and result of the transaction.
[0069] In this embodiment, various data generated during the transaction process can be collected in real time through various data acquisition devices (such as sensors, metering instruments, etc.) and interfaces, including supply information from energy suppliers, demand information from energy demanders, transaction prices, transaction times, etc. Simultaneously, the system's database retrieves the identity information and transaction status of both parties, integrating these scattered data to form a complete transaction record.
[0070] Step S108: Confirm the transaction record using a consensus mechanism.
[0071] In this embodiment, the consensus mechanism is a set of rules and algorithms that allow nodes in a blockchain network to reach a consensus on the validity of transaction records. Since a blockchain is a distributed ledger where multiple nodes jointly maintain the ledger information, the consensus mechanism ensures that all nodes recognize new transaction records and that the records are consistent, preventing malicious nodes from tampering with data and guaranteeing the security and reliability of the blockchain system.
[0072] In this embodiment, the generated transaction records can be broadcast to all nodes in the blockchain network. Upon receiving a transaction record, each node performs a preliminary verification, checking for correct format and valid signature, among other things. Each node then further verifies the transaction record according to pre-defined consensus mechanism rules. For example, in a proof-of-work mechanism, nodes need to prove their work by solving complex mathematical problems; only nodes that complete the calculations are eligible to vote. In a proof-of-stake mechanism, nodes obtain voting rights based on the number of tokens they hold and the duration of their holding. Nodes vote on the validity of the transaction records, expressing their approval or disapproval. When a certain percentage (based on the consensus mechanism) of nodes reaches a consensus on the transaction record, it is considered that the transaction record has passed the consensus mechanism's confirmation.
[0073] Step S109: After the transaction record is confirmed, the transaction record is encrypted and recorded in the blockchain.
[0074] In this embodiment, encryption is the process of converting transaction records into ciphertext using a specific algorithm. The purpose of encryption is to protect data security and privacy, ensuring that only authorized parties with the corresponding decryption key can read and understand the original data. In blockchain, encryption prevents transaction records from being stolen or tampered with during transmission and storage. Common encryption algorithms include symmetric and asymmetric encryption algorithms.
[0075] In this embodiment, a selected encryption algorithm and key can be used to encrypt transaction records confirmed through a consensus mechanism, converting the original plaintext transaction records into ciphertext transaction records. The encryption process ensures the confidentiality of the transaction records; only authorized parties with the decryption key can decrypt and read the original data. Nodes in the blockchain network package the encrypted transaction records into a new block. In addition to the transaction records, the new block also includes information such as the hash value, timestamp, and random number of the previous block; this information collectively ensures the integrity and immutability of the block. After the new block is created, it is broadcast to all nodes in the blockchain network. Each node verifies the new block, and upon successful verification, adds it to its own blockchain copy, thus completing the process of recording the encrypted transaction records in the blockchain.
[0076] The method provided in this application encrypts transaction records using encryption technology, ensuring that the records exist in ciphertext form during transmission and storage. Even if stolen, attackers cannot access the original data content, effectively protecting the information security and privacy of both parties and preventing the leakage of sensitive information. The consensus mechanism ensures consistent recognition of transaction records by all nodes, making them difficult to tamper with once recorded in the blockchain. Any modification to a transaction record requires re-reaching consensus, which is computationally very difficult. Furthermore, the chain structure of the blockchain allows each transaction record to be traced back to its source, facilitating auditing and oversight. The application of the consensus mechanism and blockchain technology makes the transaction process more transparent and fair. All nodes jointly participate in the confirmation and recording of transaction records, eliminating single points of failure and human intervention risks associated with centralized institutions. Both parties can trust the transaction information recorded by the blockchain system, enhancing mutual trust and promoting smooth transactions.
[0077] In some embodiments, step S101 can be implemented by the following steps: Step S1011: Obtain historical power generation data from the energy supplier, weather data within the preset time period, and time characteristic information.
[0078] In this embodiment, historical power generation data refers to the power generation records of the energy supplier over a past period, including power generation at different times, the operating status of power generation equipment, and power generation efficiency. This data reflects the energy supplier's historical production capacity and operational patterns. Weather data refers to weather information related to a preset time period, such as temperature, humidity, wind speed, and sunlight intensity. Weather conditions have a significant impact on the energy supplier's power generation capacity; for example, solar power generation is affected by sunlight intensity, wind power generation by wind speed, and thermal power generation may be affected by ambient temperature, impacting equipment heat dissipation. Time-related information refers to time-related features, such as the number of hours in a day, the day of the week, and whether it is a holiday. This information can reflect the regular changes in energy demand and supply at different times; for example, residential electricity demand is higher during peak evening hours, while industrial electricity demand is higher during weekday daytime hours.
[0079] In this embodiment, historical power generation data can be extracted from the energy supplier's monitoring system, data recording equipment, or energy management platform. The acquired data may include fields such as timestamps, power generation, and power generation equipment status. Weather data for a preset time period can be obtained through data interfaces with meteorological departments, professional meteorological data service platforms, or publicly available meteorological data websites. Specific weather information for the region, such as temperature, humidity, wind speed, and light intensity, can be obtained based on the energy supplier's geographical location. Some data may require further processing, such as classifying wind speeds into different levels or normalizing light intensity. Time feature information can be extracted from the system clock or calendar tools based on the preset time range. For example, date and time functions in programming languages can be used to obtain information such as the number of hours in a day, the days of the week, and whether it is a holiday, and this information can be formatted to suit the model input.
[0080] Step S1012: Input the historical power generation data, the weather data, and the time feature information into the first prediction model to obtain the energy supply of the energy supplier within the preset time period.
[0081] In this embodiment, the first prediction model is a mathematical model used to predict the energy supply from the energy supplier within a preset time period based on input historical power generation data, weather data, and time characteristic information. This model can be constructed based on machine learning algorithms (such as neural networks, decision trees, support vector machines, etc.) or statistical methods.
[0082] In this embodiment, the acquired historical power generation data, weather data, and time characteristic information can be preprocessed, including data cleaning, missing value handling, and data standardization or normalization. The preprocessed data is then organized according to the input format required by the first prediction model, for example, by organizing the data into a matrix or tensor. The organized data is then input into the first prediction model, which calculates and analyzes the input data based on its internal learning algorithm and parameters, ultimately outputting a predicted energy supply value for the energy supplier within a preset time period.
[0083] The method provided in this application comprehensively considers historical power generation data, weather data, and time characteristic information from energy suppliers. By fusing these multi-source data and inputting them into the prediction model, it can more comprehensively and accurately capture the changing patterns of energy supply, thereby improving the accuracy of prediction and reducing prediction errors.
[0084] In some embodiments, step S101 may further include: Step S1013: Obtain the historical electricity consumption data of the energy demander, the weather data and time characteristic information within the preset time period.
[0085] In this embodiment, historical electricity consumption data refers to the electricity consumption records of energy consumers over a past period, including information such as electricity consumption at different points in time, the operating status of electrical equipment, and power consumption. This data reflects the past electricity consumption habits and patterns of the consumers.
[0086] In this embodiment, historical electricity consumption data can be obtained from smart meters, energy management systems, or power company data recording systems of energy consumers. Weather data can be obtained through data interfaces with meteorological departments, professional meteorological data service platforms, or publicly available meteorological data websites.
[0087] Step S1014: Input the historical electricity consumption data, the weather data, and the time characteristic information into the second prediction model to obtain the energy demand of the energy demander during the preset time period.
[0088] In this embodiment, the second prediction model is a mathematical model used to predict the energy demand of energy consumers within a preset time period based on input historical electricity consumption data, weather data, and time characteristic information. It can be constructed using machine learning algorithms (such as linear regression, decision trees, neural networks, etc.) or statistical methods.
[0089] In this embodiment, the acquired historical electricity consumption data, weather data, and time characteristic information can be preprocessed, including data cleaning, missing value handling, and data standardization or normalization. The preprocessed data is then organized according to the input format required by the second prediction model, for example, by organizing the data into a matrix or tensor. The organized data is then input into the second prediction model, which calculates and analyzes the input data based on its internal learning algorithm and parameters, ultimately outputting a predicted energy supply value for the energy supplier within a preset time period.
[0090] The method provided in this application comprehensively considers historical electricity consumption data, weather data, and time characteristic information of energy demanders. By fusing these multi-source data and inputting them into the prediction model, it can more comprehensively and accurately capture the changing patterns of energy demand, reduce prediction errors, and provide a more reliable basis for energy supply and dispatch.
[0091] Based on the foregoing implementations, this application provides a blockchain-based energy trading method. This method is applied to a blockchain-based energy trading system, which includes a user interaction layer, a smart contract generation module, a trusted infrastructure layer (blockchain), and an oracle. In this application embodiment, the user interaction layer provides a web or mobile interface for users to intuitively set and manage their energy trading preferences and view their energy production / consumption data, trading history, revenue, and optimization suggestions provided by the system in real time. The oracle is a key bridge connecting on-chain (blockchain) and off-chain (physical world) data. It securely obtains actual energy delivery data from smart meters or data acquisition systems within the community and writes it to the blockchain, thereby triggering the settlement logic of the smart contract. The smart contract generation module receives energy supply and energy demand and matches and optimizes them with user-defined preference parameters obtained from the user interaction layer (such as "electricity sales price not lower than 0.15 yuan / kWh" and "willing to prioritize purchasing green electricity at a price 10% higher than the grid price"). Based on a predefined rule engine, specific energy trading smart contract terms are automatically generated or parameterized and deployed to the trusted infrastructure layer by calling the blockchain interface. The smart contract generation module includes an AI prediction module. The AI prediction module takes as input historical power generation / consumption data, weather data obtained from external APIs, and time characteristics (hours, weekdays / holidays), and employs a time series prediction model (such as an LSTM neural network). It outputs predicted power generation and consumption values for each producer and consumer within the community for a specific future time period (e.g., the next 24 hours). The trusted infrastructure layer deploys a blockchain network within the local energy community using consortium blockchain technology (such as Hyperledger Fabric). Each community member or key device (such as a gateway) can act as a node, collectively maintaining a distributed ledger. The final results of all energy transactions (such as the transacting parties, electricity volume, price, and timestamp) are confirmed through a consensus mechanism and recorded in encrypted form in the block, ensuring data immutability and full traceability. Transaction rules are encoded through smart contracts.
[0092] Figure 3 An interactive schematic diagram of a blockchain-based energy trading method provided in this application embodiment is shown below. Figure 3 As shown, the participants include: User A (producer), smart contract generation module, blockchain network / smart contract, oracle, and User B (consumer). The following interactions are described in chronological order: 1. AI prediction triggers; 2. Smart contract generation module generates and deploys the contract; 3. Smart contract performs contract matching (consumer purchases); 4. User A's actual energy transfer; 5. Oracle reports data; 6. Contract automatically settles.
[0093] Based on the foregoing embodiments, this application provides a specific example: It is predicted that user A (producer) will have 3.5 kWh of surplus photovoltaic power between 14:00 and 15:00 tomorrow. The smart contract generation module, combined with user A's preferences (minimum selling price of 0.12 yuan / kWh), automatically generates a sales contract and deploys it on the blockchain. The contract status is "pending matching." Scanning the pending contracts on the blockchain, it finds that user B's (consumer's) preferences (maximum purchase price of 0.13 yuan / kWh) match this contract. The "purchase" function of the contract is automatically called in user B's name, and the contract status is updated to "matched." After the 14:00-15:00 period ends tomorrow, the oracle reads from the smart meter that user A actually delivered 3.4 kWh of electricity to user B, and then calls the "settlement" function of the contract, inputting 3.4. The smart contract automatically executes the settlement according to preset rules (payment amount = 3.4 kWh * 0.12 yuan / kWh), transferring the corresponding amount from user B's account to user A's account and recording the entire transaction on the blockchain. No manual intervention is required throughout the process.
[0094] In this embodiment, the underlying blockchain is not limited to a consortium blockchain; in specific scenarios, a public blockchain can be used to obtain stronger openness and censorship resistance, or a lightweight distributed ledger technology can be used instead. Prediction can be performed using an LSTM model, or alternatively, a GRU, Transformer time series model, or an ensemble learning model, as long as the required prediction accuracy is achieved. The user interaction layer is not limited to a graphical interface; it can also integrate voice assistants, chatbots, and other interaction methods to facilitate user preference settings. In the initial stage or in a small community, some functions of the intelligent decision-making layer (such as simple rule matching) can be completed by a centralized server, with only the final transaction results and clearing instructions executed through the blockchain, serving as a transitional solution for gradual decentralization.
[0095] The method provided in this application, through blockchain technology, solves the problems of trust, optimization, and participation, laying a solid foundation for technical implementation and ensuring the system's integrity, stability, and scalability. By integrating preference parameters with AI prediction results into a driving algorithm, it dynamically generates and deploys automatically executable energy trading smart contracts. This enables forward-looking and personalized optimization of the community energy system, simplifying complex energy management into a "set preferences - auto-run" model, greatly improving the system's intelligence level and user experience. It establishes an automated energy allocation and transaction execution mechanism based on smart contracts. Using oracles, it securely and reliably inputs off-chain actual metering data into the blockchain, triggering smart contract conditions and automatically completing energy transfers and fund settlements. This achieves full-process automation of peer-to-peer transactions, eliminating intermediaries and reducing costs; it ensures the immutability and mandatory enforcement of transaction rules, establishing a transaction environment that does not require third-party trust.
[0096] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0097] According to the foregoing embodiments, this application provides a blockchain-based energy trading device. The various modules and units included in the device can be implemented by a processor in a computer device; of course, they can also be implemented by specific logic circuits. In the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.
[0098] This application provides a blockchain-based energy trading device. Figure 4 A schematic diagram of the structure of a blockchain-based energy trading device provided in this application embodiment is shown below. Figure 4 As shown, the blockchain-based energy trading device 400 includes: The first acquisition module 401 is used to acquire the energy supply of the energy supplier in a preset time period, the first preference parameter of the energy supplier, the energy demand of the energy demander in the preset time period, and the second preference parameter of the energy demander. The matching calculation module 402 is used to perform matching optimization calculations based on the first preference parameter, the energy supply, the second preference parameter and the energy demand to obtain the transaction parameters between each energy supplier and the matched energy demander. The transaction module 403 is used to generate a smart contract based on the transaction parameters and deploy the smart contract to the blockchain to conduct energy transactions between various energy suppliers and matching energy demanders based on the transaction parameters in the smart contract.
[0099] In some embodiments, the matching calculation module is specifically used for: The first preference parameter, the energy supply, the second preference parameter, and the energy demand are input into the matching optimization model to obtain the transaction parameters between each energy supplier and the matched energy demander. The matching optimization model includes a calculation relationship between minimizing the total transaction amount and maximizing the total preference matching reward. The constraints of the matching optimization model include at least one of the following: an upper limit constraint on the energy supply of the energy supplier, an upper limit constraint on the energy demand of the energy demander, a price preference constraint, and a default communication address constraint.
[0100] In some embodiments, the first preference parameter includes: supply price preference and energy type, the second preference parameter includes: demand price preference and energy preference type, and the preference matching reward is equal to the price matching reward multiplied by the price matching reward plus the type matching reward multiplied by the type matching weight, wherein the price matching reward is calculated based on the supply price preference and demand price preference, and the type matching reward is calculated based on the matching degree between energy type and energy preference type.
[0101] In some embodiments, the price matching reward is 1 if the supply price preference is less than or equal to the reference price and the reference price is less than or equal to the highest price of the demand price preference; otherwise, the price matching reward is 0. The type matching reward is 1 if the energy type and energy preference type match, and 0 if the energy type and energy preference type do not match.
[0102] In some embodiments, the blockchain-based energy trading device 400 includes: The second acquisition module is used to acquire the actual energy transaction volume when an energy transaction is completed between the target energy supplier and the matching target energy demander. The calculation module is used to calculate the transaction amount based on the actual energy trading volume and the transaction price in the smart contract; The transfer module is used to transfer the transaction amount from the account of the target energy demander to the account of the target energy supplier.
[0103] In some embodiments, the blockchain-based energy trading device 400 includes: The third acquisition module is used to acquire transaction records; The confirmation module is used to confirm the transaction records using a consensus mechanism. The recording module is used to encrypt the transaction record after the transaction record is confirmed, and record the encrypted transaction record in the blockchain.
[0104] In some embodiments, the first acquisition module includes: The first acquisition unit is used to acquire historical power generation data from the energy supplier, weather data within the preset time period, and time characteristic information. The first input unit is used to input the historical power generation data, the weather data, and the time characteristic information into the first prediction model to obtain the energy supply from the energy supplier during the preset time period, and / or, The second acquisition unit is used to acquire the historical electricity consumption data of the energy demander, the weather data and time feature information within the preset time period; The second input unit is used to input the historical electricity consumption data, the weather data, and the time characteristic information into the second prediction model to obtain the energy demand of the energy demander during the preset time period.
[0105] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0106] In addition, the blockchain-based energy trading device described above can be a software unit, a hardware unit, or a combination of both. It can also be integrated into electronic devices as an independent component or exist as an independent terminal device.
[0107] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0108] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 5 As shown, the electronic device 3 in this embodiment may include: at least one processor 30 ( Figure 5Only one processor 30, memory 31, and computer program 32 stored in memory 31 and executable on at least one processor 30 are shown. When the processor 30 executes the computer program 32, it implements the steps in any of the above method embodiments, or the processor 30 executes the computer program 32 to implement the functions of each module / unit in the above device or system embodiments.
[0109] For example, computer program 32 may be divided into one or more modules / units, one or more of which are stored in memory 31 and executed by processor 30 to complete this application. One or more modules / units may be a series of computer program 32 instruction segments capable of performing a specific function, which describe the execution process of computer program 32 in electronic device 3.
[0110] This application also provides a computer-readable storage medium storing a computer program 32, which, when executed by a processor 30, implements the steps described in the above-described method embodiments.
[0111] This application provides a computer program product that, when run on an electronic device, enables the electronic device to perform the steps described in the various method embodiments above.
[0112] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program 32 instructing related hardware. The computer program 32 can be stored in a computer-readable storage medium, and when executed by the processor 30, it can implement the steps of the various method embodiments described above. The computer program 32 includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. A computer-readable medium can include at least: any entity or device capable of carrying computer program code to a terminal, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.
[0113] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0114] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0115] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. For example, the apparatus / network device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0116] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0117] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application 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 this application, and should all be included within the protection scope of this application.
Claims
1. A blockchain-based energy trading method, characterized in that, include: The energy supply of the energy supplier during a preset time period, the first preference parameter of the energy supplier, the energy demand of the energy demander during the preset time period, and the second preference parameter of the energy demander are obtained. Based on the first preference parameter, the energy supply, the second preference parameter, and the energy demand, a matching optimization calculation is performed to obtain the transaction parameters between each energy supplier and the matched energy demander. A smart contract is generated based on the transaction parameters, and the smart contract is deployed to the blockchain to conduct energy transactions between various energy suppliers and matching energy demanders based on the transaction parameters in the smart contract.
2. The method according to claim 1, characterized in that, The matching optimization calculation based on the first preference parameter, the energy supply, the second preference parameter, and the energy demand yields the transaction parameters between each energy supplier and the matched energy demander, including: The first preference parameter, the energy supply, the second preference parameter, and the energy demand are input into the matching optimization model to obtain the transaction parameters between each energy supplier and the matched energy demander. The matching optimization model includes a calculation relationship between minimizing the total transaction amount and maximizing the total preference matching reward. The constraints of the matching optimization model include at least one of the following: an upper limit constraint on the energy supply of the energy supplier, an upper limit constraint on the energy demand of the energy demander, a price preference constraint, and a default communication address constraint.
3. The method according to claim 2, characterized in that, The first preference parameter includes: supply price preference and energy type; the second preference parameter includes: demand price preference and energy preference type; the preference matching reward is equal to the price matching reward multiplied by the price matching reward plus the type matching reward multiplied by the type matching weight; wherein, the price matching reward is calculated based on the supply price preference and demand price preference, and the type matching reward is calculated based on the matching degree between energy type and energy preference type.
4. The method according to claim 3, characterized in that, The price matching reward is 1 if the supply price preference is less than or equal to the reference price and the reference price is less than or equal to the highest price of the demand price preference; otherwise, the price matching reward is 0. The type matching reward is 1 if the energy type and energy preference type match, and 0 if the energy type and energy preference type do not match.
5. The method according to claim 1, characterized in that, The method further includes: The actual energy transaction volume is obtained when an energy transaction is completed between the target energy supplier and the matching target energy demander. The transaction amount is calculated based on the actual energy trading volume and the transaction price in the smart contract. The transaction amount is transferred from the account of the target energy demander to the account of the target energy supplier.
6. The method according to claim 5, characterized in that, The method further includes: Get transaction records; The transaction records are confirmed using a consensus mechanism. After the transaction record is confirmed, the transaction record is encrypted and recorded in the blockchain.
7. The method according to claim 1, characterized in that, The process of obtaining the energy supply volume of the energy supplier within a preset time period, the energy supplier's first preference parameter, the energy demand volume of the energy demander within the preset time period, and the energy demander's second preference parameter includes: Acquire historical power generation data from energy suppliers, weather data within the preset time period, and time characteristic information; The historical power generation data, the weather data, and the time characteristic information are input into the first prediction model to obtain the energy supply from the energy supplier during the preset time period, and / or, Acquire historical electricity consumption data of the energy demander, weather data within the preset time period, and time characteristic information; The historical electricity consumption data, the weather data, and the time characteristic information are input into the second prediction model to obtain the energy demand of the energy demander during the preset time period.
8. A blockchain-based energy trading device, characterized in that, include: The first acquisition module is used to acquire the energy supply of the energy supplier in a preset time period, the first preference parameter of the energy supplier, the energy demand of the energy demander in the preset time period, and the second preference parameter of the energy demander. The matching calculation module is used to perform matching optimization calculations based on the first preference parameter, the energy supply, the second preference parameter, and the energy demand to obtain the transaction parameters between each energy supplier and the matched energy demander. The transaction module is used to generate smart contracts based on the transaction parameters and deploy the smart contracts to the blockchain to conduct energy transactions between various energy suppliers and matching energy demanders based on the transaction parameters in the smart contracts.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 7.