Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article covers ERC1761, which proposes a standard interface for granting approvals to groups of token IDs called scopes.

This article translates, summarizes, and expands on the proposal below.

I have also covered a range of EIPs, BIPs, SLIPs, CAIPs, ENSIPs, RFCs, and ACPs.

Overview

ERC1761 introduces the concept of a scope to token contracts and defines a standard interface for granting approvals limited to a particular scope. With existing token-ID-based contracts such as ERC721 and ERC1155, applications often rely on operator approvals that grant permission over all of an owner's tokens in the contract, creating a security risk.

ERC1761 introduces scopes so that an approval can apply only to a particular group of token IDs. Developers or operators can define scopes according to the needs of their applications. Users can then grant approvals covering only the tokens that belong to a specified scope.

Scopes limit the reach of approvals and reduce unnecessary exposure. They are particularly useful for contracts that manage multiple token domains.

Abstract

The interface is intended for token contracts that use token IDs, such as ERC1155 and ERC721. Its main purpose is to provide a mechanism for granting approval over a subset of token IDs within a particular scope.

For smart contracts managing multiple token domains, it may be desirable to restrict approvals to individual domains. Scoped approval generalizes this idea: scopes divide the set of tokens into groups to which approvals can be granted separately. The implementer defines these scopes according to the intended use case.

Examples of Using Scopes

Use case Description
Corporate fleet management A company representing its vehicles as blockchain tokens could define a scope for each regional office, allowing management at the regional level.
Game development If several game developers share one ERC1155 contract, a separate scope can be defined for each developer so that they manage only their own tokens.
Separating tokens by value High-value tokens can be placed in smaller scopes and low-value tokens in a large common scope. Approving a third-party contract to operate on the low-value tokens need not expose the high-value tokens to the same risk.

Defining scopes limits the set of tokens covered by an approval, allowing flexible management that balances security and user experience.

Motivation

Many applications use operator approval mechanisms that grant permission over all of an owner's tokens within a contract. Such blanket approvals can result in significant asset losses if users do not adequately assess the security of the approved contract. Granting unrestricted operator permissions to a malicious smart contract may expose all of the user's tokens in that contract to unauthorized transfers.

Some applications therefore need a mechanism for restricting approvals. Scoped approval allows users to authorize operations on particular groups of tokens, reducing unnecessary risk.

ERC1761 does not provide a standard API for administering scopes. Scope definitions and management are implementation-dependent. Each project is expected to design these mechanisms for its own use cases.

Possible designs include the following.

Implementation type Description
Fixed scopes Define a predetermined number of scopes, each with a specific meaning.
Type-based scopes Assign tokens to scopes automatically based on their types or attributes.
User-defined scopes Allow users to create scopes and add or manage the token IDs covered by them.

Flexible scope design allows applications to implement restricted approvals according to their requirements and risk tolerance. This helps users authorize token operations with greater confidence.

Specification

ERC1761 defines a standard interface for scoped approval. A scope is a logical group of token IDs for which an approval can be set as a unit. This lets users authorize third parties to manage only their tokens that belong to a specified scope.

Complete Interface

javascript
pragma solidity ^0.5.2;

/**
    Note: The ERC-165 identifier for this interface is 0x30168307.
*/
interface ScopedApproval {
    /**
        @dev MUST emit when approval changes for scope.
    */
    event ApprovalForScope(address indexed _owner, address indexed _operator, bytes32 indexed _scope, bool _approved);

    /**
        @dev MUST emit when the token IDs are added to the scope.
        By default, IDs are in no scope.
        The range is inclusive: _idStart, _idEnd, and all IDs in between have been added to the scope.
        _idStart must be lower than or equal to _idEnd.
    */
    event IdsAddedToScope(uint256 indexed _idStart, uint256 indexed _idEnd, bytes32 indexed _scope);

    /**
        @dev MUST emit when the token IDs are removed from the scope.
        The range is inclusive: _idStart, _idEnd, and all IDs in between have been removed from the scope.
        _idStart must be lower than or equal to _idEnd.
    */
    event IdsRemovedFromScope(uint256 indexed _idStart, uint256 indexed _idEnd, bytes32 indexed _scope);

    /** @dev MUST emit when a scope URI is set or changes.
        URIs are defined in RFC 3986.
        The URI MUST point a JSON file that conforms to the "Scope Metadata JSON Schema".
    */
    event ScopeURI(string _value, bytes32 indexed _scope);

    /**
        @notice     Returns the number of scopes that contain _id.
        @param _id  The token ID
        @return     The number of scopes containing the ID
    */
    function scopeCountForId(uint256 _id) public view returns (uint32);

    /**
        @notice             Returns a scope that contains _id.
        @param _id          The token ID
        @param _scopeIndex  The scope index to  query (valid values are 0 to scopeCountForId(_id)-1)
        @return             The Nth scope containing the ID
    */
    function scopeForId(uint256 _id, uint32 _scopeIndex) public view returns (bytes32);

    /**
        @notice Returns a URI that can be queried to get scope metadata. This URI should return a JSON document containing, at least the scope name and description. Although supplying a URI for every scope is recommended, returning an empty string "" is accepted for scopes without a URI.
        @param  _scope  The queried scope
        @return         The URI describing this scope.
    */
    function scopeUri(bytes32 _scope) public view returns (string memory);

    /**
        @notice Enable or disable approval for a third party ("operator") to manage the caller's tokens in the specified scope.
        @dev MUST emit the ApprovalForScope event on success.
        @param _operator    Address to add to the set of authorized operators
        @param _scope       Approval scope (can be identified by calling scopeForId)
        @param _approved    True if the operator is approved, false to revoke approval
    */
    function setApprovalForScope(address _operator, bytes32 _scope, bool _approved) external;

    /**
        @notice Queries the approval status of an operator for a given owner, within the specified scope.
        @param _owner       The owner of the Tokens
        @param _operator    Address of authorized operator
        @param _scope       Scope to test for approval (can be identified by calling scopeForId)
        @return             True if the operator is approved, false otherwise
    */
    function isApprovedForScope(address _owner, address _operator, bytes32 _scope) public view returns (bool);
}

The interface uses ERC165 and has interface identifier 0x30168307. ERC165 provides a mechanism for discovering which interfaces a contract supports. External contracts can use it to determine whether scoped approval is supported.

For more on ERC165, see the following article.

[ERC165] Checking Whether a Contract Supports an Interface

Events

ApprovalForScope

javascript
event ApprovalForScope(address indexed _owner, address indexed _operator, bytes32 indexed _scope, bool _approved);

An event emitted when an approval changes for a scope.

The event is emitted when an operator (a third-party address) is approved or its approval is revoked for a particular scope. The _owner, _operator, and _scope parameters are indexed so that frontends and external applications monitoring approval changes can filter the events.

Parameters

  • _owner
    • The token owner's address.
  • _operator
    • The operator address covered by the approval.
  • _scope
    • The scope for which approval was granted or revoked.
  • _approved
    • The approval state.
    • true for approval and false for revocation.

IdsAddedToScope

javascript
event IdsAddedToScope(uint256 indexed _idStart, uint256 indexed _idEnd, bytes32 indexed _scope);

An event emitted when a range of token IDs is added to a scope.

It indicates that new token IDs have been added to a scope. The range is inclusive, covering every ID from _idStart through _idEnd. By default, IDs do not belong to any scope.

Parameters

  • _idStart
    • The starting ID of the range being added.
  • _idEnd
    • The ending ID of the range being added.
  • _scope
    • The scope to which the IDs are added.

IdsRemovedFromScope

javascript
event IdsRemovedFromScope(uint256 indexed _idStart, uint256 indexed _idEnd, bytes32 indexed _scope);

An event emitted when a range of token IDs is removed from a scope.

It indicates that token IDs in a specified range have been removed from a scope. The range is inclusive: all IDs from _idStart through _idEnd are removed.

Parameters

  • _idStart
    • The starting ID of the range being removed.
  • _idEnd
    • The ending ID of the range being removed.
  • _scope
    • The scope from which the IDs are removed.

ScopeURI

javascript
event ScopeURI(string _value, bytes32 indexed _scope);

An event emitted when a scope URI is set or changed.

The event records updates to the metadata URI associated with a scope. The URI follows RFC3986 and points to a JSON document containing scope metadata. The document must conform to the Scope Metadata JSON Schema described below.

Parameters

  • _value
    • The scope URI.
  • _scope
    • The corresponding scope.

Functions

scopeCountForId

javascript
function scopeCountForId(uint256 _id) public view returns (uint32);

Returns the number of scopes to which a specified token ID belongs.

This function obtains the number of scopes containing a particular token ID. Knowing the count lets callers retrieve individual scopes using scopeForId.

Parameters

  • _id
    • The token ID being queried.

Return value

  • uint32
    • The number of scopes containing the specified token ID.

scopeForId

javascript
function scopeForId(uint256 _id, uint32 _scopeIndex) public view returns (bytes32);

Returns a scope at a specified index among the scopes containing a token ID.

The function retrieves the scope at a particular zero-based index among the scopes associated with the token ID. Valid _scopeIndex values range from zero through scopeCountForId(_id)-1.

Parameters

  • _id
    • The token ID being queried.
  • _scopeIndex
    • The scope index.

Return value

  • bytes32
    • The identifier of the corresponding scope.

scopeUri

javascript
function scopeUri(bytes32 _scope) public view returns (string memory);

Returns the URI associated with a scope.

The function returns the metadata URI for the specified scope. The URI points to a JSON document containing information such as the scope's name and description. If a scope has no URI, the function can return an empty string ("").

Parameters

  • _scope
    • The scope being queried.

Return value

  • string
    • The scope's metadata URI.

setApprovalForScope

javascript
function setApprovalForScope(address _operator, bytes32 _scope, bool _approved) external;

Grants or revokes operator approval for a particular scope.

The function grants or removes an operator's permission over the caller's (msg.sender) tokens that belong to the specified scope. On success, it emits an ApprovalForScope event.

Parameters

  • _operator
    • The operator address whose approval is granted or revoked.
  • _scope
    • The relevant scope.
  • _approved
    • true to grant approval or false to revoke it.

isApprovedForScope

javascript
function isApprovedForScope(address _owner, address _operator, bytes32 _scope) public view returns (bool);

Checks the approval state for a particular scope.

The function checks whether an approval exists for the specified combination of owner, operator, and scope. External callers can use it to query approvals on a per-scope basis.

Parameters

  • _owner
    • The token owner's address.
  • _operator
    • The operator address being queried.
  • _scope
    • The scope being queried.

Return value

  • bool
    • true if approved and false otherwise.

Scope Metadata JSON Schema

The schema defines a standard JSON structure for scope metadata. Following the schema allows scope names, descriptions, and localization information to be provided consistently.

json
{
    "title": "Scope Metadata",
    "type": "object",
    "required": ["name"],
    "properties": {
        "name": {
            "type": "string",
            "description": "Identifies the scope in a human-readable way."
        },
        "description": {
            "type": "string",
            "description": "Describes the scope to allow users to make informed approval decisions."
        },
        "localization": {
            "type": "object",
            "required": ["uri", "default", "locales"],
            "properties": {
                "uri": {
                    "type": "string",
                    "description": "The URI pattern to fetch localized data from. This URI should contain the substring `{locale}` which will be replaced with the appropriate locale value before sending the request."
                },
                "default": {
                    "type": "string",
                    "description": "The locale of the default data within the base JSON"
                },
                "locales": {
                    "type": "array",
                    "description": "The list of locales for which data is available. These locales should conform to those defined in the Unicode Common Locale Data Repository (http://cldr.unicode.org/)."
                }
            }
        }
    }
}

Schema Overview

Field Type Description
name string Identifies the scope with a human-readable name.
description string Describes the scope so users can make informed approval decisions.
localization object Defines localization information.

Localization Fields

Field Type Description
uri string A URI pattern for retrieving localized data. It contains {locale}, which is replaced with the appropriate locale code.
default string The default locale of the base JSON document.
locales array The available locales, which should conform to Unicode CLDR.

Localization

This mechanism standardizes multilingual scope metadata so that clients can present scope information consistently in different languages. When the localization field is present, the client substitutes the chosen locale for {locale} in the URI and retrieves the appropriate localized data.

Localized information is applied as an overlay on the base JSON, allowing multilingual presentation while maintaining a consistent description of the scope.

Additional Considerations

The initial design of ScopedApproval was proposed as an extension to ERC1155, the multi-token standard. The original aim was to subdivide ERC1155's setApprovalForAll permissions by scope.

Several significant design changes followed discussions within the development community.

  • Initial proposal

    ScopedApproval was initially proposed as a direct extension of ERC1155. Discussed in Comment 1, this approach added scope management to the existing multi-token standard.

  1. Revising the design

    A subsequent discussion in Comment 2 proposed implementing ScopedApproval as an external contract. This reflected the view that scoped approval should be applicable to different token standards, including ERC721 and ERC1155.

  • Community proposal

    Following community feedback in Comment 3, ScopedApproval was defined as a standard interface. This allows different token standards, such as ERC721 and ERC1155, to implement scoped approvals flexibly without depending on one particular standard.

Ultimately, ScopedApproval was designed as a general-purpose interface that allows any suitable token standard to implement scoped approval. It provides a basis for consistent approval schemes across different asset-management contracts and can support future interoperability.

Metadata JSON

ScopedApproval introduces the Scope Metadata JSON Schema to associate human-readable information, including names and descriptions, with scopes.

Rather than exposing only a technical identifier (bytes32), the mechanism provides metadata that helps users understand what an approval covers.

A scope can expose a JSON document containing the following information through its URI.

Field Content
name A human-readable scope name.
description A description of the scope, including the range of permissions covered by the approval.
localization Configuration for multilingual presentation, including uri and locales.

The schema enables applications to display the meaning and reach of a scope, helping users make safer and more accurate approval decisions.

The localization field allows scope metadata to be displayed in multiple languages, supporting users around the world. The data is accessed through URIs conforming to RFC3986, so external systems can retrieve it consistently.

References

The ScopedApproval specification draws on several existing standards, implementation examples, and discussions.

Category Name / Source Description
Standard ERC1155 Multi Token Standard A standard for handling multiple token types in a single contract. ScopedApproval originated from the idea of extending this model.
Standard ERC165 Standard Interface Detection A standard for detecting the interfaces supported by a contract. ScopedApproval conforms to it and has identifier 0x30168307.
Standard JSON Schema A standard specification for defining metadata structures. The Scope Metadata JSON Schema is based on it.
Implementation example Enjin Coin (GitHub) ScopedApproval-related implementations were considered and prototyped in the Enjin project, with potential applications in NFT and game asset management.
Discussion thread GitHub - Original Discussion Thread Discussion of the initial ScopedApproval design, including its principles and requirements.
Discussion thread GitHub - ERC-1155 Discussion Thread Discussion of the original ERC1155 extension proposal and the eventual shift toward a standard interface.

Drawing on these standards and discussions, ScopedApproval evolved into a design intended to support extensibility, compatibility, and security.

Conclusion

This article covered ERC1761, a standard interface for granting approvals to groups of token IDs called scopes.

If you have questions, feel free to contact me by direct message on Twitter.

Twitter @cardene777

I also publish material on the following platforms.

https://chaldene.net/