Skip to content

Commit

Permalink
Merge 7dbf5a7 into 08405e7
Browse files Browse the repository at this point in the history
  • Loading branch information
zihaoccc committed Jul 16, 2023
2 parents 08405e7 + 7dbf5a7 commit 426ada1
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
104 changes: 104 additions & 0 deletions EIPS/eip-7336.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
eip: 7336
title: Interactive across multiple registries
description: An Universal Domain Namespace(UDoN) interface allowing for interactive capabilities across multiple registries like ENS
author: Mengshi Zhang (@MengshiZhang), Zihao Chen (@zihaoccc)
discussions-to: https://ethereum-magicians.org/t/erc7336-a-interface-allowing-for-interactive-capabilities-across-multiple-registries-like-ens/15069
status: Draft
type: Standards Track
category: ERC
created: 2023-07-14
requires: 165
---

## Abstract

The objective of this EIP is to propose the **Universal Domain Namespace(UDoN)**, which aims to facilitate onchain registry entries. Each entry in this structure adopts a mapping type, allowing for interactive capabilities across multiple registries like [ENS](./eip-137.md) and [NFT accounts](./eip-6551.md).

## Motivation

The necessity for a unified method of data retrieval across various registries is apparent. A structured methodology that allows for seamless reading of data from one registry to another, effectively linking chains of information, is thus proposed. This [EIP-7336](./eip-7336.md) seeks to standardize an interface that not only supports interaction but also promotes integration with multi-protocol registries. With the utilization of such an interface, a single deployed contract can retrieve records from different combinations of registries, such as ENS ([ERC-137](./eip-137.md)), the registry for royalty payments of NFTs ([ERC-6786](./eip-6786.md)), the registry for smart contract accounts owned by ERC-721 tokens ([ERC-6551](./eip-6551.md)), and other registries as defined by varying protocols.

## 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.

**The Universal Domain Namespace(UDoN)** is a singular contract that enables the retrieval of data from multiple registries, each defined under different protocols within its own namespace. These registries employ distinct methods for resolving the key-value pairs.

Resolving a node in **UDoN** involves a two-step process. Firstly, the **UDoN** is invoked with the protocol specified by the caller to resolve their namespace. This call returns the corresponding registry associated with that protocol. Secondly, using the key that needs resolution, if the record exists in the returned registry, the registry itself retrieves the associated value using its own implementation. This retrieval process can involve directly returning the value or utilizing a resolver.

### Typical Flow

![Typical Flow](../assets/eip-7336/workflow.png)

### Interface

A new UDoN interface is defined, consisting of the following method:

```solidity
interface IERC7336 {
struct Result {
address resAddr;
string resText;
bytes32 resAbi;
bytes32 resPublickey;
}
/// @notice Returns the multi type data by retrieving value from different registries
/// @param registryAddress An address of target registry
/// @param node A key to lookup data for
/// @return The value is retrieved from specific registry
function getValue(address registryAddress, byte32 node) external view returns (Result res);
}
```

Smart contracts implementing the [ERC-7336](./eip-7336.md) standard MUST implement all of the functions in the [ERC-7336](./eip-7336.md) interface.

## Rationale

The rationale behind this EIP is to augment the efficiency and interoperability within the Ethereum ecosystem. It provides a seamless way to interact with different registries, ultimately simplifying the process of reading and retrieving data. This proposed interface will encourage the development of more efficient, interoperable and standardized solutions, leading to a more robust and integrated Ethereum ecosystem.

## Backwards Compatibility

As this EIP introduces a new feature and does not modify any existing behaviors, there are no backwards compatibility issues.

## Reference Implementation

```solidity
pragma solidity ^0.8.12;
import "./IERC7336Interface.sol";
import "./ERC165/ERC165Query.sol";
contract RegistryInterfaceId {
bytes4 internal constant ENS_INTERFACE_ID = 0x75b24222;
bytes4 internal constant TXT_INTERFACE_ID = 0x59d1d43c;
bytes4 internal constant OTHER_INTERFACE_ID = 0x...; // Replace with the correct value for the other interface ID
}
contract UDoN is ERC165Query, IERC7336Interface {
function getValue(address registryAddress, bytes32 node) external view override returns (Result memory) {
UDoN reg = UDoN(registryAddress);
Result memory res;
if (doesContractImplementInterface(registryAddress, RegistryInterfaceId.ENS_INTERFACE_ID)) {
var resolver = reg.resolver(node);
var address = resolver.addr(node);
res.resAddr = address;
} else if (doesContractImplementInterface(registryAddress, RegistryInterfaceId.TXT_INTERFACE_ID)) {
var text = reg.getText();
res.resText = text;
}
return res;
}
}
```

## Security Considerations

Needs discussion.

## Copyright

Copyright and related rights waived via [CC0](../LICENSE.md).
Binary file added assets/eip-7336/workflow.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 426ada1

Please sign in to comment.