You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: ERCS/erc-7590.md
+4
Original file line number
Diff line number
Diff line change
@@ -179,6 +179,10 @@ Caution is advised when dealing with non-audited contracts.
179
179
180
180
Implementations MUST use the message sender as from parameter when they are transferring tokens into an NFT. Otherwise, since the current contract needs approval, it could potentially pull the external tokens into a different NFT.
181
181
182
+
When transferring [ERC-20](./eip-20.md) tokens in or out of an NFT, it could be the case that the amount transferred is not the same as the amount requested. This could happen if the [ERC-20](./eip-20.md) contract has a fee on transfer. This could cause a bug on your Token Holder contract if you do not manage it properly. There are 2 ways to do it, both of which are valid:
183
+
1. Use the `IERC20` interface to check the balance of the contract before and after the transfer, and revert if the balance is not the expected one, hence not supporting tokens with fees on transfer.
184
+
2. Use the `IERC20` interface to check the balance of the contract before and after the transfer, and use the difference to calculate the amount of tokens that were actually transferred.
185
+
182
186
To prevent a seller from front running the sale of an NFT holding [ERC-20](./eip-20.md) tokens to transfer out such tokens before a sale is executed, marketplaces MUST beware of the `erc20TransferOutNonce` and revert if it has changed since listed.
183
187
184
188
[ERC-20](./eip-20.md) tokens that are transferred directly to the NFT contract will be lost.
// Here you can either use the difference as the amount, or revert if the difference is not equal to the amount and you don't want to support transfer fees
69
+
if (newBalance + amount != initBalance) {
70
+
revertInvalidAmountTransferred();
71
+
}
64
72
65
73
emitTransferredERC20(erc20Contract, tokenId, to, amount);
66
74
_afterTransferHeldERC20FromToken(
@@ -94,7 +102,14 @@ abstract contract AbstractERC7590 is IERC7590 {
// Here you can either use the difference as the amount, or revert if the difference is not equal to the amount and you don't want to support transfer fees
0 commit comments