EIPs Explained

ERC-4974 · Stagnant · ERC · 2022-04-02

ERC-4974: Ratings

A minimal interface for an operator-controlled contract that assigns signed int8 ratings to addresses, as a non-financial, composable primitive for reputation, XP or loyalty points.

What problem does it solve?

Most on-chain primitives are assets you can buy and sell. The author argues this has hurt community projects. In 2021, DAOs and games often let money buy influence ("pay-to-play").

ERC-4974 proposes a rating that cannot be bought or transferred. A designated operator assigns it to an address, and any other contract can read it. Suggested uses include DAO voting weight, game experience points, customer loyalty points, and risk ratings for assets in an insurance protocol.

How it works

Each compliant contract has a single operator, such as a multisig, a DAO or an admin. Only the operator can change ratings. The interface is small:

Function / event Purpose
setOperator(address) Hand operator authority to a new address. Only the current operator may call it
rate(address rated, int8 rating) Assign or update a rating, emits Rating
removeRating(address removed) Remove a rating, emits Removal
ratingOf(address) Read the current rating
NewOperator, Rating, Removal Events for indexers

Design choices from the rationale:

  • int8 (−128…127). Signed, so neutral and negative ratings are possible. Small, so ratings from different contracts stay on a comparable scale.
  • Operator discretion. The standard says nothing about how the operator decides. It only fixes who can change ratings.
  • Updatable and removable. Ratings can be lowered after misconduct, or withdrawn if the rater is no longer confident in them.
  • Interface detection uses ERC-165.

Sample code

A small implementation:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract Ratings {
    event NewOperator(address indexed _operator);
    event Rating(address _rated, int8 _rating);
    event Removal(address _removed);

    address public operator;
    mapping(address => int8) private _ratings;

    constructor(address op) { require(op != address(0)); operator = op; emit NewOperator(op); }

    modifier onlyOperator() { require(msg.sender == operator, "not operator"); _; }

    function setOperator(address op) external onlyOperator {
        require(op != address(0) && op != operator, "bad operator");
        operator = op;
        emit NewOperator(op);
    }

    function rate(address who, int8 r) external onlyOperator { _ratings[who] = r; emit Rating(who, r); }
    function removeRating(address who) external onlyOperator { delete _ratings[who]; emit Removal(who); }
    function ratingOf(address who) external view returns (int8) { require(who != address(0)); return _ratings[who]; }
}

A DAO could read ratingOf(voter) to weight votes.

Things to know

  • Status: Stagnant. It was not finalized and has no known broad adoption.
  • The spec text has loose ends. The ERC-165 interface ID is left as a placeholder, some comments name events that don't match the interface (Appointment vs NewOperator, Remove vs Removal), and the rationale mentions name/description metadata functions that are never defined. Implementers would have to settle these details themselves.
  • All power sits with one operator key. The spec recommends that several parties control it, for example through a multisig.
  • The authors themselves warn that negative ratings could enable bullying or discrimination. Think about the social impact of what you publish on-chain, which is permanent and public.
  • For non-transferable credentials rather than numeric scores, see soulbound designs such as ERC-5114.

#reputation #ratings #non-transferable #dao

Details

Authors
Daniel Tedesco (@dtedesco1)
Status
Stagnant
Type
Standards Track / ERC
Created
2022-04-02
Requires

Machine-readable: Markdown · JSON