I havea project in which I need to send the readings from the sensor connected to RPi to blockchain. Due to the fact that smart contract cannot manipulate data outside blockchain I need an oracle that will modify the sensor data (to be an integer) and address it to the Ethereum blockchain. I have no idea how to write oracles and how to run the script on RPi. Please, help
Asked
Active
Viewed 770 times
0
1 Answers
1
There's nothing particularily fancy about an oracle. They are just an external source that sends regular transactions to the blockchain. The transactions are in a well-defined format which can be read within the blockchain from other contracts.
So basically you have:
- An external program that gets external data and connects to the blockchain
- A way to serialize the external data in an understandable format to be stored in the blockchain (in a smart contract)
- A smart contract that can read the serialized data and provide it for whichever contract requires it
What you do need to be worried about is deciding on how you update the data in the blockchain. Is it regularily (once a day? once a minute?) or per-request? Each update costs you some gas and each read costs gas.
Lauri Peltonen
- 29,391
- 3
- 20
- 57
-
Maybe it will update upon reaching some threshold value, or 3 times a day, won’t miners create enough gas for that? and actually I don’t know how to write a external programm and how to serialize data, however I have some thoughts about smart contract itself – Nurbolat K Feb 26 '18 at 22:54
myContract.sendData(dataToSend), if you want to send data as a sequence of bytes. If your data is more complex you can send it preprocessed, if sensor1, sensor2, .. are the integer values returned by the sensors then something like thismyContract.sendSensorData([sensor1, sensor2, sensor3])send data as an array of integers. – Ismael Feb 27 '18 at 21:43