EIP-2135: Consumable Interface
Author | Zainan Victor Zhou |
---|---|
Discussions-To | https://github.com/ethereum/EIPs/issues/2135 |
Status | Draft |
Type | Standards Track |
Category | ERC |
Created | 2019-06-23 |
Table of Contents
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. 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.
Specification
The standard will mainly contain the following interface.
The required interface
pragma solidity >=0.7.0 <0.9.0;
interface EIP2135 {
// The main consume function
function consume(uint256 _assetId) external returns(bool _success);
// The interface to check whether an asset is consumable.
function isConsumable(uint256 _assetId) external 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 ERC-721 Metadata
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.
Citation
Please cite this document as:
Zainan Victor Zhou, "EIP-2135: Consumable Interface [DRAFT]," Ethereum Improvement Proposals, no. 2135, June 2019. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2135.