-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERC-1203 Multi-Class Token Standard (ERC-20 Extension) #1203
Comments
So if I read it correctly, this is a competing proposal against #1178, right? |
@xinbenlv that wasn't our original intent but, yes, looks like we're independently trying to address the same issue. We only became aware of ERC-1178 when doing a final sync before creating the new pull request today. And after studying ERC-1178 in detail, we felt that our proposal still contains enough merits and differences (as described in the Rationale section) that warranted community consideration. Love to hear your thoughts on either or both of the ERCs :) |
Well, coming from a "traditional" Internet background, I can see how important it's for a latter protocol/standard to be backward compatible to a widely accepted existing standard(ERC-20 in this case), so I think that's a very strong advantage of ERC-1203 |
Why not add a safe transfer function? |
@HassanFahmy I agree, safe transfer together with token fallback/received is becoming expected features in token standards. I would definitely in favor of adding them. But as stated above, I've been working more with #1155 as I believe that standard provides all features of this one and more. Closing the issue for now. Thanks everyone for chiming in, and anyone who wishes to re-open or take the proposal further is certainly free to do so. Cheers! |
Simple Summary
A standard interface for multi-class tokens (MCTs).
Abstract
The following standard allows for the implementation of a standard API for MCTs within smart contracts. This standard provides basic functionality to track, transfer, and convert MCTs.
Motivation
This standard is heavily inspired by ERC-20 Token Standard and ERC-721 Non-Fungible Token Standard. However, whereas these standards are chiefly concerned with representation of items/value in a single class, fungible or note, this proposed standard focus on that of a more complexed, multi-class system. It is fair to think of MCTs as a hybrid of fungible tokens (FT) and non-fungible tokens (NFTs), that is tokens are fungible within the same class but non-fungible with that from a different class. And conversions between classes may be optionally supported.
MCTs are useful in representing various structures with heterogeneous components, such as:
Abstract Concepts: A company may have different classes of stocks (e.g. senior preferred, junior preferred, class A common, class B common) that together make up its outstanding equities. A shareholder's position of such company composites of zero or more shares in each class.
Virtual Items: A sandbox computer game may have many types of resources (e.g. rock, wood, berries, cows, meat, knife, etc.) that together make up that virtual world. A player's inventory has any combination and quantity of these resources
Physical Items: A supermarket may have many SKUs it has available for purchase (e.g. eggs, milk, beef jerky, beer, etc.). Things get added or removed from a shopper's cart as it moves down the aisle.
It's sometimes possible, especially with regard to abstract concepts or virtual items, to convert from one class to another, at a specified conversion ratio. When it comes to physical items, such conversion essentially is the implementation of bartering. Though it might generally be easier to introduce a common intermediary class, i.e. money.
Specification
ERC-20 Methods and Events (fully compatible)
Please see ERC-20 Token Standard for detailed specifications. Do note that these methods and events only work on the "default" class of an MCT.
Tracking and Transferring
totalSupply
Returns the total number of tokens in the specified
_class
balanceOf
Returns the number of tokens of a specified
_class
that the_owner
hastransfer
Transfer
_value
tokens of_class
to address specified by_to
, returntrue
if successfulapprove
Grant
_spender
the right to transfer_value
tokens of_class
, returntrue
if successfulallowance
Return the number of tokens of
_class
that_spender
is authorized to transfer on the behalf of_owner
transferFrom
Transfer
_value
tokens of_class
from address specified by_from
to address specified by_to
as previously approved, returntrue
if successfulTransfer
Triggered when tokens are transferred or created, including zero value transfers
Approval
Triggered on successful
approve
Conversion and Dilution
fullyDilutedTotalSupply
Return the total token supply as if all converted to the lowest common denominator class
fullyDilutedBalanceOf
Return the total token owned by
_owner
as if all converted to the lowest common denominator classfullyDilutedAllowance
Return the total token
_spender
is authorized to transfer on behalf of_owner
as if all converted to the lowest common denominator classconvert
Convert
_value
of_fromClass
to_toClass
, returntrue
if successfulConversion
Triggered on successful
convert
Rationale
This standard purposely extends ERC-20 Token Standard so that new MCTs following or existing ERC-20 tokens extending this standard are fully compatible with current wallets and exchanges. In addition, new methods and events are kept as closely to ERC-20 conventions as possible for ease of adoption.
We have considered alternative implementations to support the multi-class structure, as discussed below, and we found current token standards incapable or inefficient in deal with such structures.
Using multiple ERC-20 tokens
It is certainly possible to create an ERC-20 token for each class, and a separate contract to coordinate potential conversions, but the short coming in this approach is clearly evident. The rationale behind this standard is to have a single contract to manage multiple classes of tokens.
Shoehorning ERC-721 token
Treating each token as unique, the non-fungible token standard offers maximum representational flexibility arguably at the expense of convenience. The main challenge of using ERC-721 to represent multi-class token is that separate logic is required to keep track of which tokens belongs to which class, a hacky and unnecessary endeavor.
Using ERC-1178 token
We came across ERC-1178 as we were putting final touches on our own proposal. The two ERCs look very similar on the surface but we believe there're a few key advantages this one has over ERC-1178.
Backwards Compatibility
This EIP is fully compatible with the mandatory methods of ERC20 Token Standard so long as the implementation includes a "lowest common denominator" class, which may be class B common/gold coin/money in the abstract/virtual/physical examples above respectively. Where it is not possible to implement such class, then the implementation should specify a default class for tracking or transferring unless otherwise specified, e.g. US dollar is transferred unless other currency is explicitly specified.
We find it contrived to require the optional methods of ERC20 Token Standard,
name()
,symbol()
, anddecimals()
, but developers are certainly free to implement these as they wish.Test Cases
The repository at jeffishjeff/ERC-1203 contains the sample test cases.
Implementation
The repository at jeffishjeff/ERC-1203 contains the sample implementation.
References
Copyright
Copyright and related rights waived via CC0.
The text was updated successfully, but these errors were encountered: