// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; contract e2XUsernames { mapping(address => string[]) public storedData; mapping(string => bool) private dataExists; address public admin; uint256 public totalDataEntries; 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 e2xData(string memory _data) public { require(bytes(_data).length <= 9, "Data length exceeds 9 characters"); require(bytes(_data).length > 0, "Data cannot be empty"); require(!dataExists[_data], "Data already exists"); storedData[msg.sender].push(_data); dataExists[_data] = true; totalDataEntries++; emit DataStored(msg.sender, _data); } function getData(address _address) public view returns (string[] memory) { return storedData[_address]; } function getTotalDataEntries() public view returns (uint256) { return totalDataEntries; } function getUserDataCount(address _address) public view returns (uint256) { return storedData[_address].length; } function transferToNewContract(address _newContract) external 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][0]); } function changeAdmin(address _newAdmin) public onlyAdmin { require(_newAdmin != address(0), "Invalid admin address"); emit AdminChanged(admin, _newAdmin); admin = _newAdmin; } }