Skip to content

A Blcokchain and AI based renewables, carbon credit / tax and offsetting project for our efforts to combat global climate change

Notifications You must be signed in to change notification settings

KY-BChain/TransActive

Repository files navigation

BlockEnergy

A Blcokchain and AI based renewables, carbon credit / tax and offsetting project for our efforts to combat global climate change

A Business Case

Our business case will be a prosumer scenario for renewable energy trading. We will assume that the distributor runs the energy market and uses monetary incentives to balance the production and consumption of electricity.

This is similar but not identical to the real world energy markets out there. I’ve made the use case more generic because a blockchain based energy market has some computational constraints.

In a real world market the producers bet the price at which they want to produce energy for a given timeframe. The retailers buy or not specific bets from producers, usually just choosing by the lowest price available. This is exactly how a security trading market works, but that happens to be computationally too intensive for current blockchain platforms.

Design

For the simplest implementation of this energy market we will use some ERC20 token as currency, and two variables to represent the production and consumption loads in the network. We will split time into arbitrary units and aim for the production and consumption load to be as balanced as possible for each time unit.

I’m going to take some inspiration on the uniswap market and use a simple price formula that reduces the electricity price when there are more producers than consumers for a given time unit. This way, cheaper electricity will incentivize consumers to consume more and producers to produce less, balancing the network. Conversely, the price rises as the number of consumers will decrease and the number of producers will increase due to the higher prices. In all transactions the distribution network will be one of the counterparts. The distribution network will set the price. Producers will sell electricity to the distribution network. Consumers will buy electricity from the distribution network.

Before you think that I’m centralizing the distribution network, I’m not. The physical distribution network that routes energy remains unchanged, but the financial distribution network that routes money between prosumers becomes a decentralized smart contract.

I’m removing many complex features to focus on the market mechanism. I believe it is possible to implement a national energy market on the blockchain, but for the purposes of this article we must remain with a simple scenario. I’ll discuss some of the missing parts later in the article. Implementation

The main benefit of a uniswap-style market is that it is very simple. In our case the whole energy trading market fits in less than 100 lines with comments. I’ll explain here the key features and then paste the whole contract. Apologies if you have to switch back and forth a few times.

For its implementation I’m going to make the market inherit from both ERC20 and Whitelist. ERC20 gives us the tools to have a currency for payments. Whitelist allows us to restrict the market only to identified consumers and producers.

As for uniswap, the market needs to be seeded with an amount of currency. This is because there might be more producers than consumers, and the market pays to producers and charges consumers. There needs to be a bit of a margin there.

The prices are calculated by two simple formulas based on the difference between the production and consumption loads. When the consumption and production loads are exactly matched the price is a chosen base level. Please ignore all the casting between types, it’s just to protect against overflow and negative prices.

This mechanism is very simple, which suits the limited computational power of blockchain. At the same time it encourages production and consumption to be balanced. Destabilizing the network in either direction has a monetary cost. It’s important to realize that the smart contract controls the money flow, and that production and consumption orders will usually be filled for future time slots. The physical distribution network will have some knowledge of proposed consumption and production loads and can take actions to curtail them if required to balance the network.

The production of energy is allowed only to identified producers, and they just need to state their intention to produce and will immediately receive the money. Obviously this is a gross simplification and in real life the money would be held into escrow until it is certified that the power was produced.

The consumption of energy works in the same way. The consumers state their intentions and pay the price determined by the network. In real life there might be some refund if the power is not actually consumed.

Further work

There are some features that haven’t been implemented for the sake of brevity. The most important of them are as follows.

There isn’t an escrow mechanism to ensure that producers only get paid for energy they produce, as opposed to promised to produce.
There isn’t a guard against putting orders for production or consumption in the past.
Neither production nor consumption orders can be cancelled. This would be needed for example for unplanned maintenance.
The pricing formula has been simplified and would need mathematical modelling.
There is no mechanism for minting tokens except for the constructor, so the contract supply can’t be modified and customers can’t actually get funds.
The currency contract should be passed on as an address in the constructor, instead of using inheritance.
The production and consumption orders should be allowed to be for an energy amount which is in a range proportional to the current load. The current implementation would have poor performance on a national scale.

Transactive energy is a concept that refers to a decentralized system for coordinating and optimizing the generation, consumption, and storage of energy. In a transactive energy system, energy producers, consumers, and storage providers can exchange energy in real-time, based on market signals and automated negotiations, without the need for centralized control. This allows for more efficient use of energy resources, reduces the need for expensive grid infrastructure, and can enable the integration of more renewable energy sources. Transactive energy is seen as a promising solution for managing the complex and dynamic energy systems of the future.

A transactive energy system works by enabling energy producers, consumers, and storage providers to interact and exchange energy in real-time through automated negotiations and market signals. Here's a simplified overview of how a transactive energy system might work:

Energy producers, such as solar panel owners, generate energy and upload it onto the system.

Energy consumers, such as homeowners or businesses, use energy and bid on how much they are willing to pay for it.

The transactive energy system matches energy producers with energy consumers based on their bids, taking into account factors such as location, time of day, and the available energy supply and demand.

The matched energy transactions are automatically executed, and energy is delivered to the consumers.

The energy producers are paid for the energy they provide, and the consumers are charged for the energy they use.

Energy storage providers, such as battery owners, can also participate by offering to store excess energy and selling it back to the system when there is demand.

Overall, a transactive energy system enables a more decentralized, market-based approach to energy management, which can be more efficient, cost-effective, and environmentally friendly than traditional centralized systems.

In a transactive energy system, the pricing of electricity is based on supply and demand, which is determined through market-based mechanisms. Here's a simplified overview of how pricing might work:

Energy producers offer energy into the market, indicating how much energy they have available and at what price.

Energy consumers bid on how much energy they want to purchase and at what price.

The transactive energy system matches energy producers with energy consumers based on their bids, taking into account factors such as location, time of day, and the available energy supply and demand.

The market-clearing price is the price at which the supply and demand of energy are balanced, and all transactions that were bid below this price are executed.

The energy producers receive payment for the energy they provide at the market-clearing price, and the energy consumers pay for the energy they use at the same price.

By using a market-based mechanism, a transactive energy system can ensure that the pricing of electricity reflects the true supply and demand of energy, which can lead to more efficient use of energy resources and lower costs for consumers. Additionally, by incentivizing the use of renewable energy sources, a transactive energy system can also help to reduce greenhouse gas emissions and promote sustainable energy practices.

A transactive energy system requires a decentralized system that can manage the complex interactions and negotiations between energy producers, consumers, and storage providers. Some of the key characteristics of a suitable decentralized system for transactive energy include:

Distributed ledger technology: A distributed ledger technology, such as blockchain, can provide a secure and transparent way to record and manage energy transactions. Blockchain can also enable automated smart contracts to execute transactions based on pre-defined conditions.

Peer-to-peer communication: A transactive energy system requires direct communication between energy producers, consumers, and storage providers to negotiate and execute transactions. A peer-to-peer communication system, such as a mesh network, can enable direct communication between these parties without the need for centralized intermediaries.

Real-time data processing: A transactive energy system requires real-time data processing to match energy supply and demand and execute transactions. A decentralized system that can process data in real-time, such as a distributed stream processing system, can be suitable for this purpose.

Scalability and interoperability: A transactive energy system needs to be scalable and interoperable to accommodate the growing number of energy producers and consumers and to integrate with existing energy infrastructure. A decentralized system that can scale horizontally, such as a decentralized cloud platform, can be suitable for this purpose.

Overall, a suitable decentralized system for a transactive energy system should provide a secure, transparent, and scalable platform for managing energy transactions in real-time.

There are several blockchain Dapp and ecosystems that could be suitable for developing a transactive energy system, depending on the specific requirements and needs of the system. Some of the key considerations when selecting a blockchain Dapp or ecosystem for a transactive energy system include:

Scalability: A transactive energy system involves a large number of energy producers and consumers, and requires fast and efficient transaction processing. Therefore, a blockchain Dapp or ecosystem with high scalability, such as Ethereum, EOS, or TRON, could be suitable.

Smart contracts: Smart contracts are essential for executing transactions and enforcing the rules of a transactive energy system. A blockchain Dapp or ecosystem with a robust and flexible smart contract system, such as Ethereum or EOS, could be suitable.

Interoperability: A transactive energy system needs to be able to integrate with existing energy infrastructure and other blockchain ecosystems. A blockchain Dapp or ecosystem with strong interoperability features, such as Cosmos or Polkadot, could be suitable.

Governance: A transactive energy system requires a decentralized governance model to ensure the fair and transparent management of energy transactions. A blockchain Dapp or ecosystem with a well-defined and community-driven governance model, such as Tezos or Decred, could be suitable.

Energy efficiency: A transactive energy system should aim to minimize energy consumption and environmental impact. Therefore, a blockchain Dapp or ecosystem with high energy efficiency, such as Cardano, could be suitable.

Overall, the selection of a blockchain Dapp or ecosystem for a transactive energy system should be based on a careful assessment of the specific requirements and needs of the system, and an evaluation of the strengths and weaknesses of different blockchain solutions.

Integrating AI into a decentralised transactive energy system has the potential to make the system more efficient and effective. AI can bring several benefits to a transactive energy system, including:

Predictive analytics: AI algorithms can analyze data from energy producers, consumers, and storage providers to predict energy demand and supply in real-time. This can enable the system to adjust energy prices and distribution accordingly, leading to more efficient energy use.

Optimization: AI can optimize energy consumption and storage based on the energy demand and supply. AI algorithms can analyze data to determine the most efficient use of energy resources and adjust energy prices accordingly.

Smart grid management: AI can help manage the smart grid by analyzing data from connected devices and adjusting energy supply and demand in real-time. This can reduce energy waste and improve the reliability of the energy grid.

Autonomous energy trading: AI can enable autonomous energy trading by enabling smart contracts that execute based on pre-defined conditions. This can reduce the need for human intervention in energy trading and make the system more efficient.

However, integrating AI into a transactive energy system also comes with some challenges, including the need for large amounts of data, potential security concerns, and the complexity of AI algorithms. Therefore, careful consideration and testing are necessary to ensure the benefits of integrating AI into a transactive energy system outweigh the potential risks and challenges.

Artificial intelligence (AI) refers to a set of technologies and techniques that enable machines to perform tasks that typically require human-like intelligence. The major elements of AI include:

Machine learning: Machine learning is a subset of AI that involves training algorithms to identify patterns and make predictions based on data. Machine learning algorithms can improve their accuracy over time by learning from new data.

Natural language processing (NLP): NLP is an AI technique that enables machines to understand, interpret, and generate human language. NLP algorithms can be used for tasks such as language translation, sentiment analysis, and speech recognition.

Computer vision: Computer vision is an AI technique that enables machines to interpret visual data, such as images and videos. Computer vision algorithms can be used for tasks such as object recognition, facial recognition, and image classification.

Robotics: Robotics is an AI field that involves designing and developing machines that can interact with the physical world. Robotics can be used for tasks such as autonomous driving, factory automation, and healthcare.

AI functions by using algorithms and statistical models to analyze data and make predictions or decisions based on that data. The process typically involves the following steps:

Data collection: Data is collected from various sources, such as sensors, databases, or online sources.

Data preparation: The data is cleaned, organized, and prepared for analysis.

Model training: An algorithm is trained on the data to identify patterns and make predictions.

Model testing: The trained algorithm is tested on new data to evaluate its accuracy and performance.

Model deployment: The algorithm is deployed to a production environment to perform the desired task, such as making predictions or decisions.

Model maintenance: The model is monitored and updated as necessary to ensure its continued accuracy and performance.

Flow of energy, as in electricity generated by solar panels in solar PV in renewable energy, is measure by metering on generate and consuming electricity.

an AI-powered smart meter could be a suitable node in a blockchain structure for a transactive energy system. Smart meters are capable of measuring the flow of energy in real-time and can provide accurate data on energy production and consumption, which is essential for a transactive energy system.

Here are some AI-powered smart meters that could be used as nodes in a blockchain structure:

Grid4C: Grid4C is an AI-powered smart meter that uses machine learning algorithms to analyze energy data in real-time. It can predict energy demand and identify anomalies in energy consumption, which can help improve the efficiency of a transactive energy system.

Itron: Itron is an AI-powered smart meter that uses machine learning algorithms to provide real-time data on energy production and consumption. It can detect energy theft and provide insights into energy usage patterns, which can help improve the transparency and security of a transactive energy system.

Bidgely: Bidgely is an AI-powered smart meter that uses machine learning algorithms to analyze energy data and provide personalized energy insights to consumers. It can identify energy waste and suggest ways to reduce energy consumption, which can help improve the efficiency of a transactive energy system.

Sense: Sense is an AI-powered smart meter that uses machine learning algorithms to identify energy usage patterns and provide real-time data on energy production and consumption. It can detect energy waste and suggest ways to reduce energy consumption, which can help improve the efficiency of a transactive energy system.

Integrating AI-powered smart meters into a blockchain structure can provide a transparent and secure platform for energy trading, which can help reduce energy waste and promote the use of renewable energy sources.

The AI-powered smart meters that I mentioned (Grid4C, Itron, Bidgely, and Sense) are international companies that offer their products and services in multiple regions, including the United States. These companies work with utility companies, energy providers, and other organizations around the world to help improve energy efficiency, reduce waste, and promote the use of renewable energy sources. However, it's important to note that the availability of these specific smart meters may vary depending on the region and the specific requirements of the transactive energy system being developed.

There are several AI-powered smart meters available in the European Union (EU) that can be used in a transactive energy system. Here are some examples:

Smart Metering Systems (SMS): SMS is a UK-based company that provides smart metering solutions for energy providers and consumers. They offer AI-powered smart meters that use machine learning algorithms to provide real-time data on energy consumption and production.

Landis+Gyr: Landis+Gyr is a Swiss-based company that provides smart metering solutions for utilities and energy providers. They offer AI-powered smart meters that use machine learning algorithms to analyze energy data and provide insights into energy consumption patterns.

Elster: Elster is a German-based company that provides smart metering solutions for energy providers and consumers. They offer AI-powered smart meters that use machine learning algorithms to provide real-time data on energy consumption and production.

Kamstrup: Kamstrup is a Danish-based company that provides smart metering solutions for utilities and energy providers. They offer AI-powered smart meters that use machine learning algorithms to analyze energy data and provide insights into energy consumption patterns.

These are just a few examples of the many AI-powered smart meter providers in the EU. The availability of specific smart meters may vary depending on the region and the specific requirements of the transactive energy system being developed.

Capturing real-time data from AI-powered smart meters requires a robust data management system that can handle large amounts of data generated by the smart meters. Here are some ways to capture real-time data from AI-powered smart meters:

Cloud-based data management system: A cloud-based data management system can be used to capture real-time data from AI-powered smart meters. The data can be sent to a cloud-based server, where it can be processed and analyzed using machine learning algorithms.

Edge computing: Edge computing is a decentralized computing model that can be used to capture real-time data from AI-powered smart meters. Edge computing involves processing data at the edge of the network, close to the source of the data. This can help reduce latency and improve the efficiency of the data management system.

Internet of Things (IoT) platform: An IoT platform can be used to capture real-time data from AI-powered smart meters. IoT platforms provide a framework for connecting devices and collecting data. The data can then be processed and analyzed using machine learning algorithms.

Application programming interfaces (APIs): APIs can be used to capture real-time data from AI-powered smart meters. APIs provide a way for applications to communicate with each other and exchange data. Smart meter APIs can be used to retrieve data from the smart meter and integrate it into the data management system.

Capturing real-time data from AI-powered smart meters is essential for a transactive energy system, as it provides accurate and timely information on energy production and consumption. The data can be used to optimize energy usage, improve efficiency, and reduce waste.

an example of a prediction model or algorithm in a smart contract based on Ethereum. One such example is the "Augur" decentralized prediction market platform, which is built on the Ethereum blockchain.

Augur allows users to create prediction markets for a variety of events, including sports, politics, and finance. Participants can then buy and sell shares in the outcome of these events, with the value of the shares reflecting the probability of the outcome.

The prediction algorithm used by Augur is based on a combination of market forces and a reporting system. The market forces refer to the buying and selling of shares, which reflects the perceived probability of the outcome. The reporting system involves designated reporters who are incentivized to report on the outcome of the event. The accuracy of the reporters is then used to adjust the market forces and determine the final outcome.

The smart contract on the Ethereum blockchain is used to enforce the rules of the prediction market and facilitate the buying and selling of shares. The smart contract ensures that the market operates in a decentralized and transparent manner, with no single party having control over the outcome.

This is just one example of how a prediction model or algorithm can be implemented in a smart contract based on Ethereum. There are many other potential use cases for smart contracts and prediction algorithms in a transactive energy system, such as predicting energy demand and prices based on historical data and market trends.

The "Augur" decentralised prediction market platform is based on buy and sell shares. Trading activities in Financial market. A Transactive energy is about energy generation and consuming balance and the availability of energy that is to be generate and / or stored on energy requirement prediction within the network. A Ethereum network where the data is coming from the AI-powered smart meter, and structured as node in the ethereum blockchain.

It is possible to use AI-powered smart meters as nodes in the Ethereum blockchain to enable a transactive energy system. Here is an example of a smart contract in Solidity that could be used for this purpose:- In this example, the smart contract defines a TransactiveEnergy-sample contract that allows users to buy energy from the owner of the contract. The contract includes three functions:

setEnergyPrice: This function allows the owner of the contract to set the price of energy in wei.

setEnergyAvailable: This function allows the owner of the contract to set the amount of energy that is available for purchase.

buyEnergy: This function allows users to buy energy from the owner of the contract by sending ether equal to the energy price times the amount of energy they want to buy. The function checks that the payment amount is correct and that there is enough energy available, and then transfers the payment to the owner and the energy to the buyer (this part is left as TODO in the example).

This is just a simple example of a smart contract that could be used in a transactive energy system. Depending on the specific requirements of the system, additional functionality and complexity could be added to the contract.

The example of a more complete smart contract for a Transactive Energy system on the Ethereum blockchain. This example assumes that the energy generation and consumption data is coming from AI-powered smart meters that are registered as nodes in the blockchain: In this example, the TransactiveEnergy-trading contract defines a transactive energy system that allows buyers to purchase energy from sellers through trades. The contract includes the following functions:

setEnergyPrice: This function allows the owner of the contract to set the price of energy in wei.

addAvailableTrade: This function allows the owner of the contract to add an available energy trade to the list of available trades.

getNumAvailableTrades: This function returns the number of available energy trades.

getAvailableTrade: This function returns the information of an available energy trade by index.

buyEnergy: This function allows a buyer to purchase energy from an available energy trade by index. It checks that the payment amount is correct, that the trade is available, and that it has not already been filled. It then fills the trade

For an example of a complete smart contract for a transactive energy system on the Binance Smart Chain that includes pricing and trading functions: TransactiveEnergy-BNB This contract uses the OpenZeppelin library to import the IERC20 interface, which allows the contract to interact with ERC-20 tokens on the Binance Smart Chain. The contract includes the following functionality:

setEnergyPrice: Allows the owner of the contract to set the price of energy.

setEnergyAvailable: Allows the owner of the contract to set the amount of energy that is available for purchase.

buyEnergy: Allows users to buy energy from the owner of the contract by transferring the appropriate amount of tokens to the contract. The function checks that the payment amount is correct and that there is enough energy available, and then transfers the tokens to the owner and the energy to the buyer.

The contract emits events for setting the energy price and availability, as well as for when energy is bought.

Note that this contract assumes that the energy tokens are ERC-20 tokens that have been previously issued and are available for trading. If you need to create your own energy tokens, you will need to add additional functionality to the contract to handle token issuance and management.

Here's a possible code base for a Transactive Energy system on the Ethereum blockchain, including pricing, trading functions, and a complete TDD (Test Driven Development) design methodology.

This code defines a TransactiveEnergy-TDD contract on the Ethereum blockchain with functions for setting the energy price, buying and selling energy, and getting account balances. It also includes events for logging and test functions for TDD.

To test the contract, you can use the testEnergyPricing and testEnergyTrading functions to verify that the pricing and trading functions are working correctly.

Note that this is just one possible implementation and there are many different approaches to building a Transactive Energy system on Ethereum.

About

A Blcokchain and AI based renewables, carbon credit / tax and offsetting project for our efforts to combat global climate change

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages