0

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;

1 Answer 1

0

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

1
  • Great - that helps a lot - thanks Richard.
    – simbro
    Dec 23, 2021 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.