// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; contract Vault { address admin; address factory; /********* CONSTRUCTOR *********/ /** Constructor to assign the admin address **/ constructor() { admin = msg.sender; } /********* MODIFIERS *********/ /** Only the admin is given the access **/ modifier onlyAdmin(){ require(msg.sender == admin,"only Admin has the access"); _; } /** Only the factory contract is given the access **/ modifier onlyFactory(){ require(msg.sender == factory,"only Factory Contract has the access"); _; } /********* MAPPING *********/ /** IP address of a sensor is recorded corresponding to its address **/ mapping( address => string ) SensorDetails; /********* FUNCTIONS *********/ /** Set the factory address by the admin **/ function setFactory(address _factory) public onlyAdmin{ factory = _factory; } /** Write the IP address into the mapping **/ function writeSensorDetails(address _sensor, string memory _details) public onlyFactory{ SensorDetails[_sensor] = _details; } }
0.4.18