Will someone please help a noob out & tell me what I am doing wrong here?
It says that "user" is an undeclared identifier.
//SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.7;
contract UserAccounts {
mapping (address => AccountInfo) public accounts;
uint userCount = 0;
struct AccountInfo {
address user;
bool exists;
}
function accountAlreadyCreated(address user) view internal returns (bool) {
if (accounts[user].exists) {
return true;
} else {
return false;}
}
modifier duplicateDetector() {
require (AccountInfo.user.exists == false, "Wallet address already registered.");
_;
}
function createAccount() public duplicateDetector returns (bool) {
AccountInfo storage id = accounts[user]; <== Error is here.
AccountInfo.id = msg.sender;
userCount += 1;
return true;
}
Sep 5, 2021, 9:58 PM
You never declare user
Sep 5, 2021, 10:19 PM
maybe what you mean is AccountInfo storage id = accounts[msg.sender];
another error would come from AccountInfo.id = msg.sender;
probably you mean id.user = msg.sender;
probably you mean id.user = msg.sender;
Sep 5, 2021, 10:22 PM
Thanks guys
I think I just need to stop for the day
Sep 5, 2021, 10:27 PM