May I know, how to make modifier for authorization of nested mapping addresses...

Mapping(address => mapping(address => uint) public allowance;

require(msg.sender == allowance[]); // Here we must give index...

But I want to authorize all addresses in this nested mapping... not only one specific address

Appreciate your quick response.

  • 1
    To do that it is required to iterate the mapping. With just a mapping it is not possible, but you can combine a mapping with an array to store the iteration keys. Usually iterating a large array is expensive.
    – Ismael
    Apr 18, 2021 at 15:38

1 Answer 1


if you want to traverse all address, may use a map from address to an array, but this costs a lot of gas. If you only want to tell whether the address already exists, maybe use another map to maintain this kind of information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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