Complete the code to declare a mapping from address to uint.
mapping(address => uint) public [1];The mapping name is usually plural to represent multiple entries. balances is the common name for mapping addresses to uint values.
Complete the code to assign 100 to the sender's balance in the mapping.
[1][msg.sender] = 100;
You assign a value to a key in the mapping by using the mapping name, here balances, with the key msg.sender.
Fix the error in the code to correctly check if an address has a balance greater than zero.
if ([1][user] > 0) { // do something }
The mapping variable name is balances. Using balances[user] accesses the stored value.
Fill both blanks to create a mapping from address to bool and set the sender's value to true.
mapping([1] => [2]) public approved; approved[msg.sender] = true;
uint or string as value type instead of bool.The mapping key type is address and the value type is bool to store true/false values.
Fill all three blanks to create a mapping from uint to string, assign a value, and retrieve it.
mapping([1] => [2]) public names; names[[3]] = "Alice"; string memory name = names[1];
address as key type here instead of uint.address or 0.The mapping key is uint, the value is string, and the key used to assign is 1.