Solidity – Understanding the Default Value for an Uninitialized Nested Mapping

solidity

What would the default value be for an uninitialized entry in the below mapping?

i.e. how to check if an address exists in the below mapping?

mapping (address => mapping (bytes32 => uint256)) public someNestedMapping;

Best Answer

Default for uninitialized storage slots (by the size of 32 bytes, aka a word) is always the 32 bytes of zeroes.

So to test if an address is part of the mapping you would check if

someNestedMapping[yourAddress][yourBytes32] == 0

Related Topic