-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Universal Resolution #11
Draft
TateB
wants to merge
3
commits into
master
Choose a base branch
from
ensip/universal-resolution
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
--- | ||
description: A universal entrypoint for resolving ENS names. | ||
contributors: | ||
- taytems.eth | ||
ensip: | ||
created: "2024-10-14" | ||
status: draft | ||
--- | ||
|
||
# ENSIP-X: Universal Resolution | ||
|
||
## Abstract | ||
|
||
This ENSIP defines a universal entrypoint for resolving ENS names, via an interface (i.e the UniversalResolver). | ||
|
||
## Motivation | ||
|
||
The process of resolving ENS names traditionally requires multiple onchain calls, and that an implementing developer has in-depth knowledge of ENS. | ||
This is becoming more prevalent over time, especially with the introduction of wildcard resolution (ENSIP-10), and more recently cross-chain reverse resolution (ENSIP-19). | ||
These factors mean there is a relatively high burden to implement ENS, with high latency, and a large amount of developer hours to spend to understand and implement the correct resolution process. | ||
|
||
Given these factors, there are significant incentives for incorrect/incomplete ENS implementations, or implementations that do not rely on Ethereum as the source of truth. | ||
|
||
Beyond the implementation burdens, maintaining many resolution implementations means that any change to ENS resolution that an ENSIP might provide becomes a challenging task to propagate amongst the ecosystem, and as such significantly limits the growth of the ENS protocol with novel concepts. | ||
|
||
As a solution for these challenges, this specification proposes an interface that allows universally resolving any ENS name, or any reverse name. | ||
|
||
## Specification | ||
|
||
A compliant implementation of the UniversalResolver must implement the following interface: | ||
|
||
```solidity | ||
interface IUniversalResolver { | ||
function resolve(bytes calldata name, bytes calldata data) external view returns (bytes memory result, address resolver); | ||
function reverse(bytes calldata lookupAddress, uint256 coinType) external view returns (string memory name, address resolver, address reverseResolver); | ||
} | ||
``` | ||
|
||
### resolve | ||
|
||
The `resolve` function should be used by any ENS client as a complete replacement for offchain resolution methods. | ||
|
||
Similar to that of ENSIP-10, this function takes two parameters: | ||
|
||
- `name`: The DNS-encoded name to resolve | ||
- `data`: The encoded calldata for a resolver function | ||
|
||
If intending to resolve multiple requests, the `data` parameter can be encoded via the following multicall interface: | ||
|
||
```solidity | ||
interface IMulticallable { | ||
function multicall(bytes[] calldata data) external view returns (bytes[] memory results); | ||
} | ||
``` | ||
|
||
Decoding the result of a multicall should be done by using the output of the same interface. | ||
Errors are returned in the results array of a multicall, and can be checked with `len(result) % 32 == 4`. | ||
|
||
Example of a multicall: | ||
|
||
```typescript | ||
function getData(name: string) { | ||
const encodedMulticallData = encodeFunctionData({ | ||
name: "multicall", | ||
args: [ | ||
[ | ||
encodeFunctionData({ | ||
name: "addr", | ||
args: [namehash(name)], | ||
}), | ||
encodeFunctionData({ | ||
name: "text", | ||
args: [namehash(name), "url"], | ||
}), | ||
], | ||
], | ||
}); | ||
const [encodedMulticallResult, resolverAddress] = | ||
await universalResolver.resolve(dnsEncodeName(name), encodedMulticallData); | ||
const decodedMulticallResults = decodeFunctionResult({ | ||
name: "multicall", | ||
data: encodedMulticallResult, | ||
}); | ||
|
||
decodedMulticallResults.forEach((result) => { | ||
if (result.length % 32 === 4) { | ||
throw new Error("Error in result"); | ||
} | ||
}); | ||
|
||
return { | ||
results: decodedMulticallResults, | ||
resolverAddress, | ||
}; | ||
} | ||
``` | ||
|
||
The output of this function is: | ||
|
||
- `bytes`: The data returned by the resolver | ||
- `address`: The address of the resolver that resolved the name | ||
|
||
### reverse | ||
|
||
The `reverse` function can be used by any ENS client as a complete replacement for offchain reverse name resolution methods. | ||
|
||
This function takes two parameters: | ||
|
||
- `lookupAddress`: The address to resolve the name for, in **encoded** form. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should clarify what encoding - text? Binary? Examples for, eg, Ethereum and Bitcoin would be valuable. |
||
- `coinType`: The coin type to resolve the name for, as defined by ENSIP-9 and ENSIP-11. | ||
|
||
The output of this function is: | ||
|
||
- `name`: The verified reverse resolved name. | ||
- `resolver`: The address of the resolver that resolved the `addr` record for the name (i.e. forward verification). | ||
- `reverseResolver`: The address of the resolver that resolved the `name` record. | ||
|
||
## Backwards Compatibility | ||
|
||
The UniversalResolver is intended to be a complete replacement for offchain resolution methods, and should be used as such. | ||
|
||
## Security Considerations | ||
|
||
None. | ||
|
||
## Copyright | ||
|
||
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.