-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create pi_network_module_5: Storage.sol
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
..._network/features/pi_network_smart_contract_architecture/pi_network_module_5: Storage.sol
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
import "./AccessControl.sol"; | ||
|
||
contract Storage { | ||
using AccessControl for address; | ||
|
||
// Mapping of storage data | ||
mapping (string => bytes) public data; | ||
|
||
// Event emitted when new storage data is updated | ||
event NewData(string indexed key, bytes value); | ||
|
||
// Function to update storage data | ||
function updateData(string memory _key, bytes memory _value) public onlyAdmin { | ||
data[_key] = _value; | ||
emit NewData(_key, _value); | ||
} | ||
|
||
// Function to get storage data | ||
function getData(string memory _key) public view returns (bytes memory) { | ||
return data[_key]; | ||
} | ||
} |