Skip to content
Merged
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0a7eff8
First draft ccip-metadata
jefflau Sep 22, 2022
61d470f
Add more functions
jefflau Sep 22, 2022
d973f53
Add Record Keys
jefflau Sep 22, 2022
a43d393
Remove ccip vocab
jefflau Sep 22, 2022
350321b
Update ens-improvement-proposals/ensip-14-ccip-metadata.md
jefflau Mar 14, 2023
e52200e
Merge branch 'master' of github.com:ensdomains/docs into ensip-14
jefflau Mar 27, 2023
2ca5e18
Add return types, expand on MUST statement
jefflau Mar 27, 2023
ecc5ffe
Switch to graphql data type
jefflau Mar 27, 2023
beb8f9d
Merge
jefflau Mar 27, 2023
a979c83
Create graphurl endpoint and support for owned node
makoto Apr 3, 2023
67aa91c
Add comments on schema
makoto Apr 3, 2023
c697ad7
Add Open Items
makoto Apr 3, 2023
90fa9d4
Fix typo
makoto Apr 3, 2023
d27f5db
Fix typo
makoto Apr 3, 2023
d8eac7e
Merge pull request #136 from ensdomains/metadata-ensip-withowned-node
jefflau Apr 5, 2023
92c0097
Merge branch 'master' into ensip-14
makoto Aug 15, 2023
acbfbe5
Add Context (#142)
makoto Aug 15, 2023
3181488
Remove xx
makoto Aug 15, 2023
c7abdad
Modify the graph structure
makoto Aug 15, 2023
751b5ce
Changed the order of address and context
makoto Aug 15, 2023
4b3365f
Shuffle the order of context and dynamic metadata
makoto Aug 15, 2023
16299de
Revert changes
makoto Aug 15, 2023
7c1dae5
Add an explanation of context
makoto Aug 15, 2023
2d7a184
Remove implementation specific requirement for owner
makoto Aug 15, 2023
c0aafd9
Address feedbacks
makoto Aug 16, 2023
a730620
Apply suggestions from code review
makoto Aug 21, 2023
e83d4ad
Address feedback
makoto Aug 21, 2023
a388a9c
ADD isApprovedFor to both l1 and l2 contracts
makoto Aug 21, 2023
be1bbc1
Add comment
makoto Aug 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions ens-improvement-proposals/ensip-16-offchain-metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
---
description: Allows metadata to be queried on ERC-3668 enabled names
---

# ENSIP-16: Offchain metadata

| **Author** | Jeff Lau \<[email protected]> |
| ------------- | ---------------------------- |
| **Status** | Draft |
| **Submitted** | 2022-09-22 |

### Abstract

This ENSIP allows metadata to be queried directly on the resolver for ERC-3668(CCIP Read: Secure offchain data retrieval) enabled names. ERC-3668 will power many of the domains in the future, however since the retrieval mechanism uses wildcard + offchain resolver, there is no standardised way to retrieve important metadata information such as the owner (who can change the records), or which L2/offchain database the records are stored on.

### Motivation

With ERC-3668 subdomains already starting to get used by larger partners in the ENS ecosystem, it is important that there is a way of frontend interfaces to get important metadata to allow a smooth user interface. For instance the owner of a ERC-3668 enabled name would need to be known, for a UI to show whether or not the currently connected account has the rights to edit the records. If the owner was not known, the only way to know would be to make the edit and wait for failure.

This ENSIP addresses this by adding a way of important metadata to be gathered on the offchain resolver, which would likely revert and be also resolved offchain, however there is an option for it to be also left onchain if there value was static and wouldn't need to be changed often.

### Specification

The metadata should include 2 different types of info

- Offchain data storage location related info: `graphqlUrl` includes the URL to fetch the metadata.

- Ownership related info: `owner`, `isApprovedForAll` defines who can own or update the given record.

#### Context

An optional field "context" is introduced by utilizing an arbitrary bytes string to define the namespace to which a record belongs.

For example, this "context" can refer to the address of the entity that has set a particular record. By associating records with specific addresses, users can confidently manage their records in a trustless manner on Layer 2 without direct access to the ENS Registry contract on the Ethereum mainnet. Please refer to [ENS-Bedrock-Resolver](https://github.com/corpus-io/ENS-Bedrock-Resolver#context) for the reference integration

#### Dynamic Metadata

Metadata serves a crucial role in providing valuable insights about a node owner and their specific resolver. In certain scenarios, resolvers may choose to adopt diverse approaches to resolve data based on the node. An example of this would be handling subdomains of a particular node differently. For instance, we could resolve "optimism.foo.eth" using a contract on optimism and "gnosis.foo.eth" using a contract on gnosis.
By passing the name through metadata, we empower the resolution process, enabling CcipResolve flows to become remarkably flexible and scalable. This level of adaptability ensures that our system can accommodate a wide array of use cases, making it more user-friendly and accommodating for a diverse range of scenarios.

### Implementation

```solidity

interface OffChainResolver {
/** @dev Returns the owner of the resolver on L2
* @param node
* @return owner in bytes32 instead of address to cater for non EVM based owner information
*/
owner(bytes32 node) returns (bytes32 owner);

isApprovedForAll(address account, address operator) returns (boolean);
/** @dev Returns the owner of the resolver on L2
* @return name can be l2 chain name or url if offchain
* @return coinType according to https://github.com/ensdomains/address-encoder
* @return graphqlUrl url of graphql endpoint that provides additional information about the offchain name and its subdomains
* @return storageType 0 = EVM, 1 = Non blockchain, 2 = Starknet
* @storageLocation = l2 contract address
* @return context = an arbitrary bytes string to define the namespace to which a record belongs such as the name owner.
*/
function metadata(bytes calldata name)
external
view
returns (string memory, uint256, string memory, uint8, bytes memory, bytes memory)
{
return (name, coinType, graphqlUrl, storageType, storageLocation, context);
}

// Optional. If context is dynamic, the event won't be emitted.
event MetadataChanged(
string name,
uint256 coinType,
string graphqlUrl,
uint8 storageType,
bytes storageLocation,
bytes context
);
}
```

```javascript
const node = namehash('ccipreadsub.example.eth')
const resolver = await ens.resolver(node)
const owner = await resolver.owner(node)
// 0x123...
const dataLocation = await.resolver.graphqlUrl()
// {
// url: 'http://example.com/ens/graphql',
// }
```

##### GgraphQL schema

##### L1

```graphql

type Domain @entity{
id
metadata: Metadata
}

type Metadata @entity {
"l1 resolver address"
id: ID!
"Name of the Chain"
name: String
"coin type"
coinType: BigInt
"url of the graphql endpoint"
graphqlUrl: String
"0 for evm, 1 for non blockchain, 2 for starknet"
storageType: Int
"l2 contract address"
storageLocation: Bytes
"optional field to store an arbitrary bytes string to define the namespace to which a record belongs"
context: Bytes
"optional field if the name has expirty date offchain"
expiryDate: BigInt
}

type Resolver @entity {
offchain: Offchain
}
```

##### L2

```graphql
type Domain {
id: ID! # concatenation of context and namehash delimited by `-`
context: Bytes
name: String
namehash: Bytes
labelName: String
labelhash: Bytes
resolvedAddress: Bytes
parent: Domain
subdomains: [Domain]
resolver: Resolver!
expiryDate: BigInt
}

type Resolver @entity {
id: ID! # concatenation of node, resolver address and context delimited by `-`
node: Bytes
context: Bytes
address: Bytes
domain: Domain
addr: Bytes
contentHash: Bytes
texts: [String!]
coinTypes: [BigInt!]
}
```

### Backwards Compatibility

None

### Open Items

- Should `owner` and `isApprovedForAll` be within graphql or shoud be own metadata function?

### Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).