File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,15 @@ in the wild problems caused by this issue.
155
155
156
156
* example* : [ Approval.sol] ( ./src/Approval.sol )
157
157
158
+ ## Revert on Approval To Zero Address
159
+
160
+ Some tokens (e.g. OpenZeppelin) will revert if trying to approve the zero address to spend tokens
161
+ (i.e. a call to ` approve(address(0), amt) ` ).
162
+
163
+ Integrators may need to add special cases to handle this logic if working with such a token.
164
+
165
+ * example* : [ ApprovalToZero.sol] ( ./src/ApprovalToZero.sol )
166
+
158
167
## Revert on Zero Value Transfers
159
168
160
169
Some tokens (e.g. ` LEND ` ) revert when transfering a zero value amount.
Original file line number Diff line number Diff line change
1
+ // Copyright (C) 2020 d-xo
2
+ // SPDX-License-Identifier: AGPL-3.0-only
3
+
4
+ pragma solidity >= 0.6.12 ;
5
+
6
+ import {ERC20 } from "./ERC20.sol " ;
7
+
8
+ contract ApprovalToZeroToken is ERC20 {
9
+ // --- Init ---
10
+ constructor (uint _totalSupply ) ERC20 (_totalSupply) public {}
11
+
12
+ // --- Token ---
13
+ function approve (address usr , uint wad ) override public returns (bool ) {
14
+ require (usr != address (0 ), "no approval for the zero address " );
15
+ return super .approve (usr, wad);
16
+ }
17
+ }
You can’t perform that action at this time.
0 commit comments