-
Notifications
You must be signed in to change notification settings - Fork 45
Power your dApp with Verifiable Real-world Data #36
Description
Power your dApp with Verifiable Real-world Data
Welcome!
Thank you for your interest in IoTeX. You are welcome to participate in our competitions. Also, take a look at the other prizes:
- Power your dApp with Verifiable Real-world Data (this prize)
- An Analytics Dashboard for our ioTube Bridge
- Port your favorite dApp to IoTeX using Web3
Please join our Discord to discuss the bounties.
Bounty Prize
2500 USDT
to the most creative submission
The Challenge
Pebble Tracker is a multi-sensor IoT board that converts real-world phenomena into verifiable, blockchain-ready data. We would like you to create a simple dApp that gets periodically fed by these verifiable data messages containing sensor values, verifies the message signature, and takes specific actions based on the sensor's values.
Below we provide the basic specifications, but anyone is free to extend it and get creative:
- Use our Pebble Simulator to generate a set of Pebble sensor data points along with their signature.
- Create a smart contract that stores a list of "registered" devices. The contract owner can allow or block/delete devices. Anyone can "register" a new device (use the device IMEI and Public key for identification).
- The contract should have a method to receive a Pebble data message and verify both data source device and data integrity.
- The contract will reject data messages that come from non-whitelisted devices or whose signature is invalid.
- For valid data messages, The contract will take some action based on the sensor values it received (e.g., store the latest values, transfer funds if a specific event is detected, etc...)
- Create a frontend for the smart contract that allows users to log in with Metamask; allows any user to register a device, and the contract owner to allowlist, block, or delete registered devices, and displays any data relevant to the smart contract (e.g., display all devices, display latest data per device, display token transfers, contract balance, etc...)
For the Smart Contract, you are required to use Solidity 0.5.13, for the frontend we suggest our dApp sample (though not a strict requirement)
Acceptance Criteria
- Code must be clear and well documented
- Applicants work must be open-source on GitHub
- Although simple, the frontend should be clean and pleasant
- You will are allowed to be creative and build your own IoT data service, as long as all the functions described above are included
- The dApp repository must include a detailed installation & usage guide
- Additional grant via Halo Program if strongly exceeds expectation
Judging Criteria
- We will require a demo of the submission
- We will assign the prize to the dApp that uses the IoT data in the most creative way
Misc/References
Useful links
- Pebble Tracker Data Format
- Pebble Tracker Simulator
- IoTeX dApp Starter
- ecrecover solidity function
- Strings concatenation in solidity
Pebble Message Verification
Important notice: the simulator only support Linux and macOS
Data message verification is the key concept behind the verifiability of Pebble Tracker data: you can both verify the source (i.e. the device public key) of the data, and the integrity of the data in one single step using the signature included in the Pebble Tracker data messages:
...
"signature": {
"r":"4c05a4fa3eba782780a517ba03ef6fdd65e5b560a027808b47fcc6ed2b864169",
"s":"05bde29104febe10c096c550b91f5d8ed2cf0d15fe48e164ee0e9765dda76f34"
}rand s are the two components of the elliptic curve signature (using secp256k1 curve) of the data message, obtained by signing the keccak256 hash of the JSON object rendered to a string without any formatting. A possible example to verify the message signature would be the following, using the solidity ecrecover function:
// The verification function is called with all Pebble IoT data values, including the signature `r` and `s` components
function receiveData(string temperature, string latitude, string longitude, ..., bytes32 r, bytes32 s)
// buildJsonString should just rebuild the original pebble data message into an unformatted
// json string using the data passed to receiveData(), and returns the string cast to bytes
bytes32 hash = keccak256(buildJsonString(temperature, latitude, longitude, ...));
// Recover device address from the data message signature
bool hit;
address deviceAddress;
// the signature version "v" can be either 27 or 28, the device does not provide it so
// we test both of them
for (uint8 v = 27; v < 29; v++) {
deviceAddress = ecrecover(hash, v, r, s);
if (whitelist[deviceAddress] == 1) {
hit = true;
break;
}
}If ecrecover() returns a valid, non-zero address, this means that the data integrity is assured (i.e. the data passed to the contract correspond to those originally signed by the device). If the returned address is also included among the whitelisted devices then both the source and integrity of the data are verified, all is good and the contract can go ahead processing the sensors data (which is now trusted data!) and taking the specific actions required by the dApp.
IoTeX Useful Links
Discuss: Please join our Discord Dev Chat to ask questions or reach out to Simone_IoTeX on Discord if you need any help.
Docs: IoTeX Docs | Ethereum Compatibility | DID | Full Nodes