// SPDX-License-Identifier: MITpragmasolidity ^0.8.18;contract Mapping {// Mapping from address to uintmapping(address=>uint) public myMap;functionget(address_addr) publicviewreturns (uint) {// Mapping always returns a value.// If the value was never set, it will return the default value (0).return myMap[_addr]; }functionset(address_addr,uint_i) public {// Update the value at this address myMap[_addr] = _i; }functionremove(address_addr) public {// Reset the value to the default value.delete myMap[_addr]; }}
// SPDX-License-Identifier: MITpragmasolidity ^0.8.18;contract NestedMapping {// Nested mapping (mapping from address to another mapping)mapping(address=>mapping(uint=>bool)) public nested;functionget(address_addr1,uint_i) publicviewreturns (bool) {// You can get values from a nested mapping// even when it is not initializedreturn nested[_addr1][_i]; }functionset(address_addr1,uint_i,bool_boo ) public { nested[_addr1][_i] = _boo; }functionremove(address_addr1,uint_i) public {delete nested[_addr1][_i]; }}