// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract DataStorage { mapping(address => string) public storedData; mapping(string => bool) private dataExists; address public admin; event DataStored(address indexed _from, string _data); event AdminChanged(address indexed _previousAdmin, address indexed _newAdmin); event DataTransferred(address indexed _from, address indexed _to, string _data); constructor() { admin = msg.sender; } modifier onlyAdmin() { require(msg.sender == admin, "Only admin can call this function"); _; } function setData(string memory _data) public { require(bytes(_data).length <= 9, "Data length exceeds 9 characters"); require(!dataExists[_data], "Data already exists"); storedData[msg.sender] = _data; dataExists[_data] = true; emit DataStored(msg.sender, _data); } function getData(address _address) public view returns (string memory) { return storedData[_address]; } function transferToNewContract(address _newContract) public onlyAdmin { require(_newContract != address(0), "Invalid new contract address"); // Implement logic to transfer data to the new contract // For demonstration purposes, emitting an event here emit DataTransferred(address(this), _newContract, storedData[msg.sender]); } function changeAdmin(address _newAdmin) public onlyAdmin { require(_newAdmin != address(0), "Invalid admin address"); emit AdminChanged(admin, _newAdmin); admin = _newAdmin; } }