Created
September 28, 2018 11:18
-
-
Save idimitrov07/6a593d6002e306d1ff0afd1468a34dfe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.4.24; | |
| contract AssetTracker { | |
| // define new Asset object | |
| struct Asset { | |
| uint256 uuid; | |
| string name; | |
| string manufacturer; | |
| uint256 timestamp; | |
| } | |
| // create a new asset mapping | |
| mapping (uint256 => Asset) assets; | |
| mapping (uint256 => bytes32[]) assetToCheckpoint; | |
| // create new asset | |
| function createAsset(uint uuid, string name, string manufacturer) { | |
| assets[uuid] = Asset(uuid, name, manufacturer, now); | |
| } | |
| // get asset, view function | |
| function getAsset(uint256 uuid) view returns(uint256, string, string, uint256) { | |
| return (assets[uuid].uuid, assets[uuid].name, assets[uuid].manufacturer, assets[uuid].timestamp); | |
| } | |
| // add to checkpount | |
| function addCheckpoint(uint256 uuid, bytes32 message) { | |
| assetToCheckpoint[uuid].push(message); | |
| } | |
| function getCheckpoints(uint256 uuid) view returns (bytes32[]) { | |
| return assetToCheckpoint[uuid]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment