Hi @alexdemc,
… and welcome to the forum! I hope you’re enjoying the course so far 
You have a couple of issues with your solution to this assignment. If you deploy your code, you will notice that when a user calls the updateBalance() function, their balance isn’t updated in the mapping. We know this because, if you then call getBalance() with the ID of the user who just tried to update their balance, the old balance is still returned.
These are the errors in your code — see if you can correct them so that your code works as it should:
This line of code is comparing two values, and not assigning a value to the user’s “record” in the mapping. This expression evaluates to true or false, but as the result isn’t saved or handled anywhere, this line of code has no effect, and so is redundant.
Because your code in the updateBalance() function body currently only reads the contract state, but doesn’t modify it, that’s why the compiler would have prompted you to make it a view
function. However, when you correct the code so that the new balance is assigned to the mapping, your function will need to modify the contract state, and view
will generate a compiler error.
One other observation…
You have started the struct and contract names with lower case letters. The convention is to start these with capital letters. This helps us to distinguish these from the names of functions, variables, mappings, parameters/arguments, and the data types string
, uint
, bool
etc.
For example, by naming your struct user
instead of User
, it isn’t immediately clear that your mapping contains struct instances, or that your local _user storage variable creates a pointer to a specific struct instance in the mapping. Your code will still compile and work with the names you have used (all starting with lower case letters), but it makes your code less readable and less manageable for other Solidity developers, who are used to the naming conventions.
Let me know if anything is unclear, or if you have any questions about how to correct your code 