# 简要说明

An interface marking certain digital assets being consumable.

# 摘要

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".

# 动机

Being a digital assets sometimes means a consumable power. One most common seen examples would be a concert ticket. It will be "consumed" at the moment the ticket-holder uses the ticket to get access to enter a concert.

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

# 规范

The standard will mainly contain the following interface.

# 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);
}
1
2
3
4
5
6
7
8
9
10
11
12

# 原理阐述

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

# 向后兼容

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

# 实现

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

# 测试用例

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

# Reference

# Standards

# 版权

Copyright and related rights waived via CC0.