# MEP-03: Sensor Data Contract
**Created**: 2023-04-19
## Simple Summary
Specification that allows the application owner (MEP-01) to create device profiles and link profiles to devices.
## Abstract
## Motivation
## Terminology
- Sensor Profile - Goes to Chirpstack VM
- Decode function
- IoT Parameter
- Custom Parameter
- Freq
- Custom Parameter
- The Chirpstack VM publish the data in the reward call
- Goes inside the sensor NFT (on-chain data)
- Is claimed in the MEP05
The reward calculation should be done on Chirpstack VM
MEP05 is to claim the rewards, not to calculate rewards (off-chain worker)
(there is an opportunity to remove MEP05 if the claim is done on MEP04)
## Specification
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
Every MEP-03 compliant contract must implement the following interface:
```solidity=
pragma solidity ^0.4.20;
/// @title MEP-03 Provisioning Contract
interface IMEP03 {
/// @notice Gets fired when a new device profile
/// is created
event CreateDeviceProfile(uint256 indexed _appId, uint256 indexed _profileId, string _metadataLink);
/// @notice Gets fired when a existing device profile
/// gets updated
event UpdateDeviceProfile(uint256 indexed _appId, uint256 indexed _profileId, string _metadataLink);
/// @notice Returns the address owning the device profile
///
/// @param _tenantId ID of the tenant on MEP-01
/// @param _appId The ID of the application on MEP-01
/// @param _profileId ID of the profile
/// @return Address of the profile owner
function ownerOfProfile(uint256 _tenantId, uint256 _appid, uint256 _profileId) external view returns (address);
/// @notice Creates a device profile with a link to IPFS
///
/// @param _tenantId ID of the tenant on MEP-01
/// @param _appId The ID of the application on MEP-01
/// @param _profileId ID of the profile
/// @param _metadataLink Metadata link to IPFS
function createDeviceProfile(uint256 _tenantId, uint256 _appId, uint256 _profileId, string _metadataLink) external;
/// @notice Updates a device profile with a link to IPFS
///
/// @param _tenantId ID of the tenant on MEP-01
/// @param _appId The ID of the application on MEP-01
/// @param _profileId ID of the profile
/// @param _metadataLink Metadata link to IPFS
function updateDeviceProfile(uint256 _tenantId, uint256 _appId, uint256 _profileId, string _metadataLink) external;
}
```
TODO
Add Codec
Upload FW for update
Edit/Add version of device profile/codec
Validate device profile/codec
## Rationale
MEP-03 needs a link to MEP-01 for the query of the tenant and application entries.
The `createDeviceProfile` needs to check whether the tenant and application exist and if the caller is eligible to create a device profile under the given tenant and application.
Device profile encapsulates how the device transmits data and the protocol attributes (LoRaWAN spec). Prior to the `createDeviceProfile` method, the caller needs to upload the device profile JSON on a distributed storage (IPFS) and supply the IPFS link to the method.