forked from DecentralizedClimateFoundation/DCIPs
162 lines
10 KiB
Markdown
162 lines
10 KiB
Markdown
---
|
|
eip: 4974
|
|
title: Ratings
|
|
description: An interface for assigning and managing numerical ratings
|
|
author: Daniel Tedesco (@dtedesco1)
|
|
discussions-to: https://ethereum-magicians.org/t/8805
|
|
status: Review
|
|
type: Standards Track
|
|
category: ERC
|
|
created: 2022-04-02
|
|
requires: 165
|
|
---
|
|
|
|
## Abstract
|
|
|
|
This standard defines a standardized interface for assigning and managing numerical ratings on the Ethereum blockchain. This allows ratings to be codified within smart contracts and recognized by other applications, enabling a wide range of new use cases for tokens.
|
|
|
|
## Motivation
|
|
|
|
Traditionally, blockchain applications have focused on buying and selling digital assets. However, the asset-centric model has often been detrimental to community-based blockchain projects, as seen in the pay-to-play dynamics of many EVM-based games and DAOs in 2021.
|
|
|
|
This proposal addresses this issue by allowing ratings to be assigned to contracts and wallets, providing a new composable primitive for blockchain applications. This allows for a diverse array of new use cases, such as:
|
|
|
|
- Voting weight in a DAO: Ratings assigned using this standard can be used to determine the voting weight of members in a decentralized autonomous organization (DAO). For example, a DAO may assign higher ratings to members who have demonstrated a strong track record of contributing to the community, and use these ratings to determine the relative influence of each member in decision-making processes.
|
|
|
|
- Experience points in a decentralized game ecosystem: Ratings can be used to track the progress of players in a decentralized game ecosystem, and to reward them for achieving specific milestones or objectives. For example, a game may use ratings to assign experience points to players, which can be used to unlock new content or abilities within the game.
|
|
|
|
- Loyalty points for customers of a business: Ratings can be used to track the loyalty of customers to a particular business or service, and to reward them for their continued support. For example, a business may use ratings to assign loyalty points to customers, which can be redeemed for special offers or discounts.
|
|
|
|
- Asset ratings for a decentralized insurance company: Ratings can be used to evaluate the risk profile of assets in a decentralized insurance company, and to determine the premiums and coverage offered to policyholders. For example, a decentralized insurance company may use ratings to assess the risk of different types of assets, and to provide lower premiums and higher coverage to assets with lower risk ratings.
|
|
|
|
This standard is influenced by the [EIP-20](./eip-20.md) and [EIP-721](./eip-721.md) token standards and takes cues from each in its structure, style, and semantics.
|
|
|
|
## Specification
|
|
|
|
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
|
|
|
|
Every compliant contract MUST implement the following interfaces:
|
|
|
|
```
|
|
// SPDX-License-Identifier: CC0
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
/// @title EIP-4974 Ratings
|
|
/// @dev See https://eips.ethereum.org/EIPS/EIP-4974
|
|
/// Note: the EIP-165 identifier for this interface is #######.
|
|
/// Must initialize contracts with an `operator` address that is not `address(0)`.
|
|
interface IERC4974 /* is ERC165 */ {
|
|
|
|
/// @dev Emits when operator changes.
|
|
/// MUST emit when `operator` changes by any mechanism.
|
|
/// MUST ONLY emit by `setOperator`.
|
|
event NewOperator(address indexed _operator);
|
|
|
|
/// @dev Emits when operator issues a rating.
|
|
/// MUST emit when rating is assigned by any mechanism.
|
|
/// MUST ONLY emit by `rate`.
|
|
event Rating(address _rated, int8 _rating);
|
|
|
|
/// @dev Emits when operator removes a rating.
|
|
/// MUST emit when rating is removed by any mechanism.
|
|
/// MUST ONLY emit by `remove`.
|
|
event Removal(address _removed);
|
|
|
|
/// @notice Appoint operator authority.
|
|
/// @dev MUST throw unless `msg.sender` is `operator`.
|
|
/// MUST throw if `operator` address is either already current `operator`
|
|
/// or is the zero address.
|
|
/// MUST emit an `Appointment` event.
|
|
/// @param _operator New operator of the smart contract.
|
|
function setOperator(address _operator) external;
|
|
|
|
/// @notice Rate an address.
|
|
/// MUST emit a Rating event with each successful call.
|
|
/// @param _rated Address to be rated.
|
|
/// @param _rating Total EXP tokens to reallocate.
|
|
function rate(address _rated, int8 _rating) external;
|
|
|
|
/// @notice Remove a rating from an address.
|
|
/// MUST emit a Remove event with each successful call.
|
|
/// @param _removed Address to be removed.
|
|
function removeRating(address _removed) external;
|
|
|
|
/// @notice Return a rated address' rating.
|
|
/// @dev MUST register each time `Rating` emits.
|
|
/// SHOULD throw for queries about the zero address.
|
|
/// @param _rated An address for whom to query rating.
|
|
/// @return int8 The rating assigned.
|
|
function ratingOf(address _rated) external view returns (int8);
|
|
}
|
|
|
|
interface IERC165 {
|
|
/// @notice Query if a contract implements an interface.
|
|
/// @dev Interface identification is specified in EIP-165. This function
|
|
/// uses less than 30,000 gas.
|
|
/// @param interfaceID The interface identifier, as specified in EIP-165.
|
|
/// @return bool `true` if the contract implements `interfaceID` and
|
|
/// `interfaceID` is not 0xffffffff, `false` otherwise.
|
|
function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
|
}
|
|
```
|
|
|
|
## Rationale
|
|
|
|
### Rating Assignment
|
|
|
|
Ratings SHALL be at the sole discretion of the contract operator. This party may be a sports team coach or a multisig DAO wallet. We decide not to specify how governance occurs, but only *that* governance occurs. This allows for a wider range of potential use cases than optimizing for particular decision-making forms.
|
|
|
|
This proposal standardizes a control mechanism to allocate community reputation without encouraging financialization of that recognition. While it does not ensure meritocracy, it opens the door.
|
|
|
|
### Choice of int8
|
|
|
|
It's signed: Reviewers should be able to give neutral and negative ratings for the wallets and contracts they interact with. This is especially important for decentralized applications that may be subject to malicious actors.
|
|
|
|
It's 8bit: The objective here is to keep ratings within some fathomably comparable range. Longer term, this could encourage easy aggregation of ratings, versus using larger numbers where users might employ a great variety of scales.
|
|
|
|
### Rating Changes
|
|
|
|
Ratings SHOULD allow rating updates by contract operators. If Bob has contributed greatly to the community, but then is caught stealing from Alice, the community may decide this should lower Bob's standing and influence in the community. Again, while this does not ensure an ethical standard within the community, it opens the door.
|
|
|
|
Relatedly, ratings SHOULD allow removal of ratings to rescind a rating if the rater does not have confidence in their ability to rate effectively.
|
|
|
|
### Interface Detection
|
|
|
|
We chose Standard Interface Detection ([EIP-165](./eip-165.md)) to expose the interfaces that a compliant smart contract supports.
|
|
|
|
### Metadata Choices
|
|
|
|
We have required `name` and `description` functions in the metadata extension. `name` common among major standards for blockchain-based primitives. We included a `description` function that may be helpful for games or other applications with multiple ratings systems.
|
|
|
|
We remind implementation authors that the empty string is a valid response to `name` and `description` if you protest to the usage of this mechanism. We also remind everyone that any smart contract can use the same name and description as your contract. How a client may determine which ratings smart contracts are well-known (canonical) is outside the scope of this standard.
|
|
|
|
### Drawbacks
|
|
|
|
One potential drawback of using this standard is that ratings are subjective and may not always accurately reflect the true value or quality of a contract or wallet. However, the standard provides mechanisms for updating and removing ratings, allowing for flexibility and evolution over time.
|
|
|
|
Users identified in the motivation section have a strong need to identify how a contract or community evaluates another. While some users may be proud of ratings they receive, others may rightly or wrongly receive negative ratings from certain contracts. Negative ratings may allow for nefarious activities such as bullying and discrimination. We implore all implementers to be mindful of the consequences of any ratings systems they create with this standard.
|
|
|
|
## Backwards Compatibility
|
|
|
|
We have adopted the `name` semantics from the EIP-20 and EIP-721 specifications.
|
|
|
|
## Reference Implementation
|
|
|
|
A reference implementation of this standard can be found in the assets folder.
|
|
<!-- [../assets/EIP-4974/ERC4974.sol](../assets/EIP-4974/ERC4974.sol). -->
|
|
|
|
## Security Considerations
|
|
|
|
One potential security concern with this standard is the risk of malicious actors assigning false or misleading ratings to contracts or wallets. This could be used to manipulate voting weights in a DAO, or to deceive users into making poor decisions based on inaccurate ratings.
|
|
|
|
To address this concern, the standard includes mechanisms for updating and removing ratings, allowing for corrections to be made in cases of false or misleading ratings. Additionally, the use of a single operator address to assign and update ratings provides a single point of control, which can be used to enforce rules and regulations around the assignment of ratings.
|
|
|
|
Another potential security concern is the potential for an attacker to gain control of the operator address and use it to manipulate ratings for their own benefit. To mitigate this risk, it is recommended that the operator address be carefully managed and protected, and that multiple parties be involved in its control and oversight.
|
|
|
|
Overall, the security of compliant contracts will depend on the careful management and protection of the operator address, as well as the development of clear rules and regulations around the assignment of ratings.
|
|
|
|
## Copyright
|
|
|
|
Copyright and related rights waived via [CC0](../LICENSE.md).
|