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
If we have transfer fees in the future, what behavior do we actually want? Some sane options:
Option 1:transfer(recipient, value) deducts the fee from value:
balanceOf(msg.sender) -= value
balanceOf(recipient) += value - fee
balanceOf(feeTaker) += fee
Option 2:transfer(recipient, value) passes all of value to the recipient, and the sender pays a bit more:
balanceOf(msg.sender) -= value + fee
balanceOf(recipient) += value
balanceOf(feeTaker) += fee
Pros and cons:
In Option 1, you can cleanly transfer out the entire balance of an account. In Option 2, this would require computing just the right value such that value + fee equals the balance that you intend.
In Option 2, you can cleanly pay an exact amount to a recipient that requires that they wind up with a specific balance. In Option 1, this would, again, require the sender to compute just the right value based on the fee schedule.
Option 2 seems to more closely follow ERC-20, where the definition of transfer includes that it "Transfers _value tokens to address _to." Nowhere does it say that it transfers _value tokens away from the sender's address.
Option 3: In light of this, it seems to me that the ideal solution is to support both options as separate functions, where Option 2 gives the semantics of the transfer function, and Option 1 is implemented under some similar name (relocate? send?). Or, perhaps Option 4, where transfer is implemented only as in Option 2, and we implement transferAll(recipient) specifically for the case where someone wants to transfer all of their tokens.
The text was updated successfully, but these errors were encountered:
I think we certainly want both options in some capacity, so it's between 3 and 4. I think I have a slight preference for #4. The main problem with #2 on its own has to do with what you do when you are sending your entire balance, and transferAll addresses that concern. Going with #3 feels like excessive generality and doesn't quite adhere to a single coherent philosophy, while #4 maintains the property that in all situations a specified value results in the recipient actually receiving that value.
If we have transfer fees in the future, what behavior do we actually want? Some sane options:
Option 1:
transfer(recipient, value)
deducts the fee fromvalue
:Option 2:
transfer(recipient, value)
passes all ofvalue
to the recipient, and the sender pays a bit more:Pros and cons:
value
such thatvalue + fee
equals the balance that you intend.value
based on the fee schedule._value
tokens to address_to
." Nowhere does it say that it transfers_value
tokens away from the sender's address.Option 3: In light of this, it seems to me that the ideal solution is to support both options as separate functions, where Option 2 gives the semantics of the
transfer
function, and Option 1 is implemented under some similar name (relocate
?send
?). Or, perhaps Option 4, wheretransfer
is implemented only as in Option 2, and we implementtransferAll(recipient)
specifically for the case where someone wants to transfer all of their tokens.The text was updated successfully, but these errors were encountered: