Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP-2229: Ping Interface #2229

Open
nachomazzara opened this issue Aug 5, 2019 · 0 comments

Comments

@nachomazzara
Copy link

commented Aug 5, 2019

eip: 2229
title: EIP-2229: Ping Interface
author: Ignacio Mazzara <nachomazzara@gmail.com>
status: Active
type: Standards Track
category: ERC
created: 2019-08-03

Abstract

Almost every asset created by Ethereum smart contracts has owners. Owners can lose their keys, but not only. We believe that by having a way to re-assign inactive assets, new owners can continue creating value from them. With this proposal, we want to standardize a ping mechanism for Ethereum smart contracts that can be used for all sorts of assets.

Motivation

This EIP is motivated by the need to reduce the impact of having inactive assets. There are a lot of crypto-collectibles/games with tokens that can interact together increasing the user experience.

For example:

  • Decentraland is a virtual world divided by parcels (ERC-721), each parcel can have content. If for some reason, a parcel owner lost his keys, the parcel can not be updated anymore. In case it has never had content, as a Decentraland's user you will see an empty parcel.

  • Other games like CryptoKitties, MyCryptoHeroes, etc have assets that can interact together. In case of a loss, the experience could be limited.

No existing EIPs for ping assets found.

This EIP proposes a light-weight interface for keeping active assets and reassigning inactive ones. This abstraction layer can sit on top of standards like ERC-721 or others where an inactive asset can diminish and limit the user experience.

Specification

The interface will expose two simple methods to be implemented as desired to include the mechanism on an Ethereum smart contract.

pragma solidity >=0.4.22 <0.6.0;


/**
 * @title Ping interface. EIP-2227
 */
interface IPing {
    /**
     * @dev Ping your account.
     */
    function ping() external;
    
    /**
     * @dev Check if a token is active or not.
     * @param _tokenId - token id to check.
     * @return Whether the token is active or not.
     */
    function isActive(uint256 _tokenId) external returns (bool);
    
    event Ping(address indexed _owner);
}

Interface ID

 bytes4 internal constant _INTERFACE_ID_PING = 0xde9963bd;
 /*
 0xde9963bd === 
    bytes4(keccak256('ping()')) ^
    bytes4(keccak256('isActive(uint256)'));
 */

Possible usage

This is a possible and super simple implementation of each method. They should have the desired business logic.

Ping

Address level methods used to set sort kind of last active timestamp.

function ping() public {
    lastActive[_owner] = block.timestamp;
    emit Ping(_owner);
}

isActive

Check if a token is active. For existing assets, a grace period can be used to do the math.
Disclaimer: The block.timestamp is used knowing that miners could manipulate it. Moreover, as it is in seconds and refers to dates, I do not imagine a real case where an arithmetic overflow occurs.

uint256 activePeriod = 4 weeks * 12; // One year

function isActive(uint256 _tokenId) public returns (bool) {
    address owner = ownerOf(_tokenId);
    return lastActive[owner].add(activePeriod) >= block.timestamp;
}

Optional Extension

This interface can be extended to manage how inactive assets will behave.

Ping another account

Ping someone else's account. It can be used within a role system.

/**
 * @dev Ping someone else's account.
 * @param _owner - desired account to ping.
 */
function ping(address _owner) public {
    require(hasAccess(_owner), "The sender does not have access");
    ping(_owner);
}

reActivate

Assign a new owner to an inactive token.

 /**
 * @dev Assign a new owner for an inactive token.
 * @param _newOwner - new owner for the token.
 * @param _tokenId - token id.
 */
function reActivate(address _newOwner, uint256 _tokenId) public {
    require(!isActive(_tokenId), "The token is active");
    ownerOf[_tokenId] = _newOwner;    
    lastActive[_newOwner] = block.timestamp;
}

@nachomazzara, @eordano and @decentraland team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.