ERC-4974 Rating (reputation score) interface (Ratings)
Stagnant · Other · created 2022-04-02
A standard that lets a contract's operator assign an integer reputation score in the range -128 to 127 to a wallet or another contract, and lets other apps query it in a standardized way.
Why it is needed
Without this standard, there is no standardized way to record and share non-monetary reputation information, such as community contribution or trustworthiness, on-chain. The original text points out that in 2021, EVM-based games and DAOs saw asset-centric models drift toward structures where participation required paying money. If each service built its own reputation logic separately, scores meant for different purposes, such as a DAO's voting weight, a game's experience points, loyalty points, or an insurer's asset risk assessment, could not be read or reused in the same way by other apps or contracts. As a result, reputation stays locked inside each individual service, and no composable foundation emerges for recognizing community contribution along an axis other than money.
What to implement
event NewOperator(address indexed _operator);: An event emitted when the operator changes.event Rating(address _rated, int8 _rating);: An event emitted when the operator assigns a rating to an address.event Removal(address _removed);: An event emitted when the operator removes a rating from an address.function setOperator(address _operator) external;: Transfers the contract's operator authority to a new address.function rate(address _rated, int8 _rating) external;: Assigns an integer rating to the specified address.function removeRating(address _removed) external;: Removes the rating assigned to the specified address.function ratingOf(address _rated) external view returns (int8);: Queries the rating assigned to the specified address.function supportsInterface(bytes4 interfaceID) external view returns (bool);: Checks whether this contract supports a specific interface (EIP-165).
In depth
Core functions and event rules
rate(_rated, _rating) must emit a Rating event on every call, removeRating(_removed) must emit a Removal event, and setOperator(_operator) must emit a NewOperator event. The specification states that each event must be emitted ONLY by its corresponding function. ratingOf(_rated) must be recorded so that it reflects the value each time a Rating event occurs, and querying the zero address should throw.
Single-operator authority structure
The contract must be initialized with a non-zero operator address. setOperator must throw if msg.sender is not the current operator, and it must also throw if the new operator address equals the current operator or is the zero address. The original Rationale explains that this operator could be a sports team's coach, or it could be a multisig DAO wallet; the standard does not prescribe the specific form of governance, only requiring that some form of governance exist.
Why int8 was chosen
Rating values are signed 8-bit integers (int8). The sign is included because decentralized applications that may interact with malicious actors need to be able to express neutral or negative assessments as well. The range is limited to 8 bits so that ratings stay within a comparable range, allowing ratings to be aggregated easily over the long term instead of each user employing a different, arbitrarily large numbering system.
Modifying and withdrawing ratings
Ratings should be updatable by the operator. The original text gives the example of Bob, who had contributed significantly to the community but later stole from Alice, as a case where the community might decide to lower someone's reputation and influence. It should also be possible to remove (withdraw) a rating, in case the operator becomes unsure of their own judgment.
Interface detection based on EIP-165
This standard adopts EIP-165's standard interface detection method so that a contract can announce externally which interfaces it supports. supportsInterface(bytes4) must run under 30,000 gas, letting a caller check with a bool whether the given interfaceID is supported.
Description of metadata (name, description)
The Metadata Choices section of the original Rationale explains that the name and description functions were required for the metadata extension; name follows the convention established by EIP-20 and EIP-721, while description is useful for things like games that use multiple rating systems. An empty string is also a valid response, and determining which rating contract is canonical is outside the scope of this standard. However, the actual interface code presented in the Specification section does not include the name or description functions.
Status: Stagnant
This proposal (EIP-4974) is currently Stagnant, a proposal that is no longer actively discussed and has stalled. The interfaces and rules described here are not yet a finalized standard and may change or be abandoned in the future.
Things to watch out for
- Risk of manipulation through false or misleading ratings: A malicious actor could assign false or misleading ratings to manipulate a DAO's voting weight, or to lead users into making poor decisions based on inaccurate ratings.
- Correctable through rating updates and removal: The standard includes mechanisms for updating or removing ratings, so false or misleading ratings can be corrected once discovered.
- Risk of compromise of the single operator address: If an attacker gains control of the operator address, they can manipulate ratings for their own benefit. To reduce this risk, it is recommended to manage and protect the operator address carefully and to involve multiple parties in control and oversight.
- Absence of rating operation rules: The security of the contract depends not only on managing and protecting the operator address but also on establishing clear rules and regulations for assigning ratings.