ERC-1203 Multi-class token standard (ERC-1203 Multi-Class Token Standard (ERC-20 Extension))

Stagnant · Tokens · created 2018-07-01

Extends ERC-20 to manage multiple classes (kinds) of tokens together within a single contract, and also supports conversion between classes.

Why it is needed

Because ERC-20 can only handle one kind of token, it is difficult to express structures where items are interchangeable within the same kind but must be distinguished from other kinds, such as a company's different classes of stock (preferred, common, etc.), various resources in a game (wood, stone, meat, etc.), or multiple products in a store. Creating a separate ERC-20 contract per class plus a separate coordinating contract for conversion is cumbersome, and simulating this with ERC-721 by treating each token as unique is inefficient because it requires separate logic to track which class each token belongs to. In this situation, concepts such as converting between classes or expressing total supply on a single common basis are also hard to handle in a standardized way.

What to implement

In depth

ERC-20 compatible methods

The ERC1203 contract inherits ERC20. totalSupply(), balanceOf(address), transfer(address,uint256), approve(address,uint256), allowance(address,address), transferFrom(address,address,uint256), and the Transfer and Approval events behave identically to the ERC-20 specification, but these methods apply only to the MCT's default class. This means that whether an MCT is newly created or an existing ERC-20 token is extended with this standard, wallets and exchanges can query and transfer the default class like an ERC-20 token without any modification.

Per-class query, transfer, and approval

Versions of the ERC-20 methods with an added _class parameter are also defined. totalSupply(uint256 _class) returns the total supply of that class, and balanceOf(address _owner, uint256 _class) returns the amount of that class held by _owner. transfer(address _to, uint256 _class, uint256 _value) transfers tokens of a specific class, approve(address _spender, uint256 _class, uint256 _value) grants transfer authority for a specific class, and allowance(address _owner, address _spender, uint256 _class) queries that authorized amount. transferFrom(address _from, address _to, uint256 _class, uint256 _value) transfers tokens of a specific class on behalf of another party within the approved amount.

Transfer and Approval events

The Transfer(address indexed _from, address indexed _to, uint256 _class, uint256 _value) event, which includes class, is emitted when tokens are transferred or newly created, including zero-value transfers. The Approval(address indexed _owner, address indexed _spender, uint256 _class, uint256 _value) event is emitted when an approve call succeeds. Both events distinguish which class the event occurred in via _class.

Fully diluted queries

fullyDilutedTotalSupply() returns the total supply across all classes converted into the smallest common unit, the least common denominator class. fullyDilutedBalanceOf(address _owner) returns the total amount held by _owner across all classes converted the same way, and fullyDilutedAllowance(address _owner, address _spender) returns the total amount across all classes that _spender can transfer on behalf of _owner. These functions make it possible to compare holdings scattered across multiple classes on a single basis.

Conversion between classes (convert)

convert(uint256 _fromClass, uint256 _toClass, uint256 _value) converts _value of _fromClass tokens into _toClass tokens at a set conversion rate, and returns true on success. The interface block in the specification body declares the event emitted when this operation completes as event Convert(uint256 indexed _fromClass, uint256 indexed _toClass, uint256 _value), but the detailed specification section immediately below writes the equivalent event as event Conversion(...), so the naming is inconsistent between the two.

Conditions for backward compatibility

For this standard to be fully compatible with ERC-20's required methods, the implementation must have a least common denominator class. In the body's examples, this corresponds to class B common for abstract concepts, gold coins for virtual items, and currency for physical goods. If such a class cannot be established, the implementation must define a default class to be used when no specific class is given for tracking or transfers, similar to how USD is applied automatically when not explicitly specified. Optional ERC-20 methods such as name(), symbol(), and decimals() are not forcibly required, and developers may implement them as they see fit.

Comparison with alternatives

The original text examines three alternatives. Having a separate ERC-20 token per class plus a conversion coordinator contract does not fit the goal of managing multiple classes with a single contract. Treating each token as unique with ERC-721 is unnecessarily complex because it requires separate logic to track which class each token belongs to. Compared with the similarly structured ERC-1178, this standard differs in that it extends ERC-20 to remain fully compatible with existing wallets and exchanges, lets existing ERC-20 contracts be extended as is to support additional classes, and introduces conversion and dilution concepts between classes to unify each class into a single system.

Proposal status

This proposal is registered as Stagnant. That is, it is no longer being actively discussed or changed and has stalled, and it may be revised and finalized in the future, or it may remain stalled indefinitely.

Original ERC · ← ERCs