You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IoT backend with Swarm and Ethereum smart contracts
Using Ethereum + Swarm as an IoT backend
IoT gateways, which are relatively powerful LoRa/NB-IoT devices, may be used to push collected data to torrent-like Swarm file storage network via HTTP.
Created file handles are stored in Ethereum blockchain using a smart contract named vendor.sol.
By using Swarm as the storage service and Ethereum blockchain as the file explorer, it is possible to create a generic backend for IoT device manufacturers.
Smart contract interface
# check if device is present i.e. has ever pushed any datafunctionis_device_present (address device_id) public constant returns (bool result);
# get total device countfunctionget_device_count() public constant returns (uint count);
# enumerate device id'sfunctionget_device_at_index (uint index) public constant returns (address device_address);
# get timestamp values containing data (for a specific device)functionget_device_timestamps (address device_id) public constant returns (uint[] timestamp);
# get stored file hashes (handles) with certain timestamp (for a specific device)functionget_device_data (address device_id, uint timestamp) public constant returns (string hash);
# push file hashes (handles) into the chainfunctionset_device_data (address device_id, string filehash) public returns (uint index, uint timestamp);
# event to log action
event log_action (address indexed device_id, uint index, uint timestamp, string filehash);