SensorSource is a demo application built from a SmartContract for Ethereum and a number of python scripts which allow the interaction with this smart contract. The goal of the application is to demonstate a way to collect sensor data for the use in other smart contracts.
IMPORTANT: This demo application is not tested with regards to security or upgrade-ability. Never use directly in production.
- Register a sensor with their meta data stored on IPFS
- Subscribe to this sensor referencing the request list
- Sensor receives the subscription, fetches the request from IPFS and collects the requested data
- Sensor stores results in IPFS then publishes its hash
- Data consumer receives the publication and accesses the data via IPFS
./Readme.md
: This file./testnet/
: Ethereum test network data./testnet/genesis.json
: A description of the first block of the Ethereum test network used for this demo./testnet/keystore/*
: A list of key files representing the accounts used by default by the python scripts. All keys are encrpyted, but use an empty password.
./python/
: Python scripts./python/requirements.txt
: Listing of required python packages. For setup, runpip install -r requirements.txt
./python/sensorSource/__init__.py
: SensorSource library implementation./python/sensorSource/contracts/sensorSource.sol
: SensorSource SmartContract implementation./python/deployContract.py
: Bootstrap script to first deploy the SensorSource contract on the test net./python/registerSensor.py
: Register a sensor on an existing SensorSource contract./python/registeredSensors.py
: Show the existing sensors on a SensorSource contract, meant to illustrate the use of the event log as a registry./python/sensorDataConsumer.py
: Start a long-running consumer waiting for the data of a specific sensor to be published./python/sensor.py
: Start a long-running process emulating a sensor. It waits for subscriptions to itself and publishes sensor data./python/subscribeToSensor.py
: Generate a subscription to a sensor - this triggers the actual data collection on the sensor via the smart contract../python/sensorDataPinning.py
: Demonstration of IPFS-based data replication. This is a long-running script waiting for the publication of any event including an IPFS hash and then pins this hash. Pinning a hash makes IPFS replicate this file to the local node.
./demo/
: Tmux-based demo script. See https://blog.dbi-services.com/using-tmux-for-semi-interactive-demos/./demo/setup-demo.sh
: Shell-script to set up a demo execution of the SensorSource system using tmux and alacritty on a mac../demo/presentation.yml
: Alacritty configuration for the demo window - bigger font, fullscreen, etc../demo/demo-script
: Sequence of tmux commands which are executed line-by-line during the demonstration
-
Deploy SensorSource Contract
-
Instantiate SensorSource Contract
-
Create SensorOwner address
-
Create sensor
- Create sensor address, aka sensorId
- Create & publish sensor meta data on IPFS, convert resulting hash to multi-hash (function, length, data) triple
- SensorOwner registers sensorId with meta data multi-hash on contract
-
Create sensor user for sensorId
- Requires user address aka SensorUser
- Create & publish sensor request list of length X data on IPFS, convert resulting hash to multi-hash triple
- SensorUser subscribes to sensorId with sensor request list multi-hash for X entries on contract
-
Activate sensor
- Sensor watches for subscription event of its id
- For each request, counting down:
- acquire data
- bundle into file & publish on IPFS (convert resulting hash to multi-hash triple)
- SensorId publish result-multi hash with count down on contract
-
Consume data
- SensorUser watches for publication of result
- Pull result from IPFS
-
Replicate data
- Watch for any publication of result
- Pin hash on IPFS to replicate it