> For the complete documentation index, see [llms.txt](https://docs.frequencychain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frequencychain.org/12.-energy-data-layer-integration/12.6-energy-data-consumption-in-smart-contract.md).

# 12.6 Energy Data Consumption in Smart Contract

Below is a simplified example demonstrating how a smart contract can consume energy data.

```
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract EnergyDataConsumer {

    uint256 public latestEnergyValue;

    function updateEnergyData(uint256 _value) public {
        latestEnergyValue = _value;
    }

    function getEnergyData() public view returns (uint256) {
        return latestEnergyValue;
    }
}
```

In a production environment, the updateEnergyData function would typically be restricted to trusted oracle addresses, ensuring that only verified data can be submitted.
