ERC-1761 Scoped approval interface

Stagnant · NFTs & multi-token · created 2019-02-18

An interface that groups token IDs into "scopes" so operator permissions can be granted to a third party only within that scope. It applies to ID-based tokens such as ERC-721 and ERC-1155.

Why it is needed

In existing token standards, granting approval to a third party (operator) usually hands over permission for all tokens held by the wallet at once. If a user does not thoroughly vet the contract they are approving, they risk losing even their high-value tokens along with the rest. Also, when multiple issuers or departments share a single token contract, there is no standard way to separately manage each one's token ID ranges. ERC-1761 reduces this problem by providing an interface that divides token IDs into arbitrary scopes and lets approval be restricted at the scope level.

What to implement

In depth

Basic concept of scopes

A scope is an arbitrary group identified by a bytes32 value, grouping together one or more token IDs. According to the source text, a token ID does not belong to any scope by default. Implementers define scopes and add or remove ID ranges via the IdsAddedToScope and IdsRemovedFromScope events. Such a range includes _idStart and _idEnd, where _idStart must be less than or equal to _idEnd. Whether scopes are fixed in number or user-creatable is left up to the implementation rather than specified by the standard.

Approval and query functions

setApprovalForScope(_operator, _scope, _approved) changes operator approval status within the specified scope and must emit an ApprovalForScope event on success. isApprovedForScope(_owner, _operator, _scope) queries whether that owner has approved that operator for that scope. scopeCountForId(_id) returns the number of scopes the given ID belongs to, and scopeForId(_id, _scopeIndex) queries each scope using an index from 0 to scopeCountForId(_id)-1.

Scope metadata URI

scopeUri(_scope) returns a URI in RFC 3986 format, and this URI must point to a JSON document conforming to the 'Scope Metadata JSON Schema'. It may return an empty string for scopes that have no URI. The ScopeURI event fires when a scope's URI is set or changed.

Scope Metadata JSON Schema and localization support

In Scope Metadata JSON, the name field is required and description is optional. Adding a localization property enables multi-language support, requiring three fields: uri (where the client substitutes the literal string {locale} with an actual locale value), default (the locale of the default data), and locales (the list of supported locales, per the Unicode CLDR standard).

ERC-165 identifier and applicable targets

The ERC-165 identifier for this interface is 0x30168307. It is designed to be used with token contracts that have an ID domain, such as ERC-1155 or ERC-721.

Design background

It was originally proposed as an extension of ERC-1155 itself, but during discussion it was decided to split it into a separate interface not tied to any specific token standard. This lets multiple ID-based token standards, such as ERC-721 and ERC-1155, implement scope approval optionally rather than being forced to.

Proposal status

This proposal is in Stagnant status. Written in 2019, it has seen no further progress and may never be changed or adopted going forward.

Original ERC · ← ERCs