EIPs Explained

ERC-1203 · Stagnant · ERC · 2018-07-01

ERC-1203: ERC-1203 Multi-Class Token Standard (ERC-20 Extension)

A proposed ERC-20 extension for multi-class tokens, where one contract holds several classes that are fungible within a class and optionally convertible between classes, like share classes or game resources.

What problem does it solve?

ERC-20 describes one fungible asset; ERC-721 describes unique items. Many real systems sit in between: a company with several share classes, a game with wood, stone and food, a shop with many SKUs. Each unit is interchangeable with others of the same class, but not across classes.

You could deploy one ERC-20 per class plus a separate converter, but that spreads one system over many contracts. ERC-1203 proposes a single contract that manages all classes while still looking like a normal ERC-20 to existing wallets and exchanges.

How it works

  • ERC-20 compatible. The usual six ERC-20 functions and two events remain and operate on a "default" class, ideally the "lowest common denominator" class (for example common stock or a base coin).
  • Per-class overloads. Every ERC-20 function gets a version with an extra _class argument: totalSupply(_class), balanceOf(_owner, _class), transfer(_to, _class, _value), approve, allowance, transferFrom. Transfer and Approval also get class-aware versions.
  • Conversion. convert(_fromClass, _toClass, _value) exchanges one class for another at an implementation-defined ratio.
  • Fully diluted views. fullyDilutedTotalSupply(), fullyDilutedBalanceOf(owner) and fullyDilutedAllowance(owner, spender) report totals as if everything were converted into the lowest common denominator class.

The authors compare it with ERC-1178, a similar multi-class proposal, and argue the advantage here is ERC-20 backward compatibility and built-in conversion.

Sample code

The interface from the spec, in modern Solidity:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IERC1203 /* is IERC20 */ {
    event Transfer(address indexed from, address indexed to, uint256 class_, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 class_, uint256 value);
    event Conversion(uint256 indexed fromClass, uint256 indexed toClass, uint256 value);

    function totalSupply(uint256 class_) external view returns (uint256);
    function balanceOf(address owner, uint256 class_) external view returns (uint256);
    function transfer(address to, uint256 class_, uint256 value) external returns (bool);
    function approve(address spender, uint256 class_, uint256 value) external returns (bool);
    function allowance(address owner, address spender, uint256 class_) external view returns (uint256);
    function transferFrom(address from, address to, uint256 class_, uint256 value) external returns (bool);

    function fullyDilutedTotalSupply() external view returns (uint256);
    function fullyDilutedBalanceOf(address owner) external view returns (uint256);
    function fullyDilutedAllowance(address owner, address spender) external view returns (uint256);
    function convert(uint256 fromClass, uint256 toClass, uint256 value) external returns (bool);
}

Things to know

  • Status is Stagnant. For new multi-asset contracts, ERC-1155 is the established standard for "many token types in one contract".
  • Overloaded functions with the same name (balanceOf(address) vs balanceOf(address,uint256)) are legal in Solidity but awkward in some tooling; in ethers you must call them by full signature, e.g. token["balanceOf(address,uint256)"].
  • The spec is inconsistent about the conversion event: the interface calls it Convert, the description calls it Conversion.
  • The conversion ratio and who may convert are not specified; each implementation must define and document them.

#token #multi-class #erc20-extension

Details

Authors
Jeff Huang <[email protected]>, Min Zu <[email protected]>
Status
Stagnant
Type
Standards Track / ERC
Created
2018-07-01

Machine-readable: Markdown · JSON