Openzeppelin-contracts: Prevent common transfer mistakes in StandardToken

Created on 9 Jun 2017  路  8Comments  路  Source: OpenZeppelin/openzeppelin-contracts

Maybe we should add checks to prevent:

  • sending to 0x0 address
  • sending to self (the token contract)

See: https://github.com/status-im/status-network-token/blob/2152b17aa2ef584a2aea95533c707a345c6ccf69/contracts/MiniMeToken.sol#L214

good first issue

Most helpful comment

I just realized the phrase "Agree with your gas concerns" can be very funny if taken out of context ^^

All 8 comments

Why do you think this would be beneficial @maraoz ?

I tend to dislike deviations from standard ERC20 functions gas costs. Do you think those edge cases justify the sum of every agent losing a bit more gas in every transaction?

(Genuinely interested in getting everyone's opinion, these are not rhetorical questions 馃槃 )

Agree with your gas concerns @GNSPS.
The design direction we're taking is making StandardToken super secure and gas-intensive, and later we want to add a gas-optimized version with less security precautions.

I just realized the phrase "Agree with your gas concerns" can be very funny if taken out of context ^^

Laughed hard! 馃槀

Actually it depends on the case, sometimes it makes sense to spend ~8k gas for the above checks, however the StandardToken is definitely not the case.

Just for the record, a single require of a comparison between a state variable and a constant costs about 60 gas.

@maraoz we have been reviewing this issue, and while I agree on preventing sends to 0x0, I can think of some scenarios where the StandardToken is extended with additional functionality and is expected to hold some of its own tokens. WDYT about adding that restriction into a SaferToken (see https://github.com/OpenZeppelin/zeppelin-solidity/pull/447/), instead of on the Standard Token?

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shyheim103 picture shyheim103  路  4Comments

LogvinovLeon picture LogvinovLeon  路  4Comments

bh2smith picture bh2smith  路  4Comments

ryana picture ryana  路  4Comments

xiaoyao1991 picture xiaoyao1991  路  3Comments