In most ERC721 setApprovalForAll() implementations, to revoke approval, the mapping is set to 0, instead of deleting the entry. I wonder what happens if many users have many approvals revoked, wouldn't deleting save a lot of storage in the mapping?

To put it into code, it would look like I have a mapping:

mapping(address => mapping(address => bool)) private _operatorApprovals;

What is the difference between delete _operatorApprovals[owner][operator]; and _operatorApprovals[owner][operator] = 0;

Thank you in advance.


  1. delete is the same as setting to default value. StackExchange.
  2. mapping does not keep track of the keys, nor does it have a length. Medium.

2 Answers 2


delete _operatorApprovals[owner][operator] is the same as _operatorApprovals[owner][operator] = 0 because there is no null value in Solidity and setting the value to 0 is the same as deleting it.

See: Why set value to 0 rather than deleting it?


It is the same in Solidity. Deleting the value or setting the value as 0

Your Answer

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

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