I wonder why data insertion in users
occurs only once, while userCount
updates correctly?
pragma solidity >=0.4.22 <0.7.0;
contract TestChainStorage {
address private owner;
uint256 public userCount;
struct User {
uint256 userNumber; // User number at registration time
uint256 regTime; // Registration time (unixTime)
string userName;
address userWallet;
}
User[] public users;
modifier isOwner() {
require(msg.sender == owner, "Caller is not owner");
_;
}
constructor() public {
owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
}
function store(uint256 unixtime, string memory username) public {
userCount++;
users.push(User({
regTime : unixtime,
userName : username,
userWallet : msg.sender,
userNumber : userCount
}));
}
function compareWallet (string memory a, string memory b) internal pure returns (bool){
return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))) );
}
function kill() public isOwner {
selfdestruct(msg.sender);
}
}
Any help appreciated!