EIP-2135 (ERC): Consumable Interface

Hi community members, I’d like to call for a early stage vetting of the idea of having a standard for consumable. Thank you!


eip: 2135
title: Consumable Interface
author: Zainan Victor Zhou (@xinbenlv)
discussions-to: https://github.com/ethereum/EIPs/issues/2135
status: Draft
type: Standards Track
category: ERC
created: 2019-06-23
requires (*optional): N/A
replaces (*optional): N/A

ERC: Consumable Interface

Simple Summary

An interface marking certain digital assets being consumable.

Abstract

The interface identifies functions and events needed for creating a contract to be able to mark a digital asset as “consumable”, and react to the request of “consumption”.

Motivation

Being a digital assets sometimes means a consumable power. A most common seen example would be a concert ticket. It will be “consumed” at the moment the ticket-holder use the ticket to get access to enter a concert.

By having a standard ERC interface, the Ethereum ecosystem can interoperate to provide service, clients, UI, and inter-contract functionalities on top of this very general use-case.

Specification

The standard will mainly contain the following interfaces.

The required interface

pragma solidity ^0.5.8;

contract EIP2135 {
  // The main consume function
  function consume(uint256 assetId) public returns(bool success);

  // The interface to check whether an asset is consumable.
  function isConsumable(uint256 assetId) public view returns (bool consumable);

  // The interface to check whether an asset is consumable.
  event OnConsumption(uint256 indexed assetId);
}

Rationale

The function consume performs the consume action. Being an interface standard,
this EIP does not impose any assumption of

  • who has the power to perform such activity.
  • under what condition such consumption can occur.

It does, however, assume the asset can be identified in a uint256 assetId as in th parameter. A design convention and compatibility consideration is put in place to follow the ERC-721

The event notifies subscribers whoever are interested to learn an asset is being consumed. The boolean function of isConsumable can be used to check whether an asset is still consumable.

To keep it simple, this standard intentionally contains no functions or events related to creation of a consumable asset. This is because the creation of a consumable asset will need to make assumption of the nature of an actual use-case. If we see some common use-case of creation, we can have another follow up standard.

We also left out metadata associated to the consumables from the standard. If necessary, related metadata can be created with a separate metadata extension interface like ERC721Metadata

Backwards Compatibility

This interface is designed to be compatible with ERC-721.

Implementation

A reference implementation accompany with tests of ERC-721 based ticket contract is built and you can found it here.

See Github/xinbenlv/eip-2135/impl

Test Cases

See Github/xinbenlv/eip-2135/impl/test

Reference

Standards

Copyright

Copyright and related rights waived via CC0.

Updated with a reference implementation.