1

Are really mind blogging!

I am having difficulties to check which version of Token I am handling when I am creating a new contract.

How can I easily tell the token that I need to transfer is ERC20 or ERC223 or ERC677? (in addition to 721)

(I know 677 is more downward compatible to 20 compare to 223)

In my opinion, all these will get out of control sooner or later unless we implement a simple field in the contract just to tell which version this token is

Example:

string public tokenSpec;

function MyToken() public {
    tokenSpec = "ERC223";
}

2 Answers 2

1

Ethereum has a mechanism for this - ERC165 - which allows contacts to report which interfaces they implement. Unfortunately it doesn't yet seem to be widely used by token contracts. There's currently no safe way of handling all three simultaneously (which is ironic, given that the newer variants were intended to increase safety), so your best bet is to either have separate code for each token type (and ideally make sure your UI knows the types of all the tokens you'll deal with, so your users can't get it wrong), or choose a subset that can be handled safely (such as ERC-20 and ERC-677) and only support that.

0

I think a decent developer would make it clear either through comments or constructors which protocol is being utilized for that particular token for example from Guaranteed Entrance Token (GET), when looking at the contract's code through EtherScan.io, I found this to be the first 12 lines of code.

/**
 * @title ERC20Basic
 * @dev Simpler version of ERC20 interface
 * @dev see https://github.com/ethereum/EIPs/issues/179
 */
contract ERC20Basic {
  uint256 public totalSupply;
  function balanceOf(address who) constant returns (uint256);
  function transfer(address to, uint256 value) returns (bool);
  event Transfer(address indexed from, address indexed to, uint256 value);
}

From the tokens that I have reviewed in a similar manner, I have found little deviance from this, but ultimately I agree that there should be a field for stating the token protocol, but not sure how realistic it is for that to be consistently done across all projects.

Your Answer

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

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