From 1e93ea0145f96bad1054fdf0ae864b91abf2cacc Mon Sep 17 00:00:00 2001 From: Luc Date: Mon, 23 Sep 2024 09:46:54 +0000 Subject: [PATCH 1/9] Introduce template --- ensips/x.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 ensips/x.md diff --git a/ensips/x.md b/ensips/x.md new file mode 100644 index 0000000..8d7aafe --- /dev/null +++ b/ensips/x.md @@ -0,0 +1,51 @@ +--- +description: Some description about the proposal +contributors: + - ens.eth +ensip: + created: '2024-01-01' + status: draft +--- + +# ENSIP-X: Title of the proposal + +## Abstract + +A short description of the proposal outlining the purpose of the proposal and the changes it proposes. + +## Motivation + +In your motivation you have room to explain why this proposal is important and why it is a good idea. + +## Specification + +Your specification goes here and should be as detailed as possible. +It is possible include images, diagrams, example payloads, requests, etc, please use markdown and links to ipfs or other resources. +You can do this using `![image description goes here](https://ipfs.io/ipfs/...)` + +Or you can create links using `[text](https://eips.ethereum.org/EIPS/eip-137)` + +Feel free to create subheadings as needed using the `###` and (sub sub sub headings) `####` markdown syntax. + +## Rationale + +Optional rationale for the proposal. +Here you can elaborate why certain decisions were made. + +## Backwards Compatibility + +Optional backwards compatibility section. +Here you can explain how this proposal affects existing systems. + +## Forwards Compatibility + +Optional forwards compatability section. +Here you can explain how this proposal affects future systems, or potential upgrade paths. + +## Security Considerations + +Optional security considerations section. + +## Copyright + +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). From 9b2dd44f6dafe3fbe52bae133682f734db194498 Mon Sep 17 00:00:00 2001 From: Luc Date: Tue, 1 Oct 2024 10:15:47 +0000 Subject: [PATCH 2/9] Update --- ensips/x.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/ensips/x.md b/ensips/x.md index 8d7aafe..44c5274 100644 --- a/ensips/x.md +++ b/ensips/x.md @@ -7,25 +7,38 @@ ensip: status: draft --- -# ENSIP-X: Title of the proposal +# ENSIP-X: EOA Chain Id ## Abstract -A short description of the proposal outlining the purpose of the proposal and the changes it proposes. +This ENSIP specifies a way to set an EOA/Fallback address for a name. This allows for users to set one address to be used for all chains, or as a fallback for when a chain-specific address record is not set. ## Motivation -In your motivation you have room to explain why this proposal is important and why it is a good idea. +With the rising interest and research around account abstraction, in addition to the maturation of the multi-chain ecosystem, there is a need for users to be able to set a single address to be used across all chains. + +For a simple EOA user, this means setting their address once, and never having to worry about it again. +For more advanced users, this means that chain-specific records can be used for smart-contract wallets, and an EOA can be specified as fallback. ## Specification -Your specification goes here and should be as detailed as possible. -It is possible include images, diagrams, example payloads, requests, etc, please use markdown and links to ipfs or other resources. -You can do this using `![image description goes here](https://ipfs.io/ipfs/...)` +This ENSIP aims to extend the functionality introduced in [ENSIP-9](./9) and [ENSIP-11](./11) and simply relies on the same functionality. + +### CoinType for EOA + +The standard CoinType for this proposed chain id is `2147483648`. + +This is derived from `evmChainIdToCoinType(0)`, as per [ENSIP-11](./11). + +### Resolution Order + +- first normal cointype lookup for the chain designated +- then lookup for eoa chain id -Or you can create links using `[text](https://eips.ethereum.org/EIPS/eip-137)` +### Proposed Implementation -Feel free to create subheadings as needed using the `###` and (sub sub sub headings) `####` markdown syntax. +- universal resolver magic +- example client implementation ## Rationale From 23291349e33bec75d2d2bfe0f2aca20a3e77bcaf Mon Sep 17 00:00:00 2001 From: Luc Date: Tue, 1 Oct 2024 10:46:07 +0000 Subject: [PATCH 3/9] Introduce examples --- ensips/x.md | 61 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 11 deletions(-) diff --git a/ensips/x.md b/ensips/x.md index 44c5274..473c677 100644 --- a/ensips/x.md +++ b/ensips/x.md @@ -1,13 +1,13 @@ --- -description: Some description about the proposal +description: A standard for storing EOA/Fallback addresses in ENS. contributors: - - ens.eth + - luc.eth ensip: - created: '2024-01-01' + created: '2024-10-01' status: draft --- -# ENSIP-X: EOA Chain Id +# ENSIP-X: EOA/Fallback Chain Id ## Abstract @@ -40,12 +40,7 @@ This is derived from `evmChainIdToCoinType(0)`, as per [ENSIP-11](./11). - universal resolver magic - example client implementation -## Rationale - -Optional rationale for the proposal. -Here you can elaborate why certain decisions were made. - -## Backwards Compatibility + + + +## Appendix A: Example Implementation + +Do note that the implementations below are the current implementations, and may change in the future. + +### Viem Example + +```typescript +import { getEnsAddress } from "viem/actions"; +import { mainnet, optimism } from "viem/chains"; +import { createPublicClient, http } from "viem"; +import { evmChainIdToCoinType } from '@ensdomains/address-encoder/utils'; + +const client = createPublicClient({ transport: http(), chain: mainnet }) + +const name = "luc.eth"; +const targetChain = optimism; + +// First lookup the targetChain address +const target_address = await getEnsAddress(client, { name, coinType: evmChainIdToCoinType(targetChain.id) }); + +// Then lookup the EOA address if needed +const address = target_address || await getEnsAddress(client, { name, coinType: evmChainIdToCoinType(0) }); +``` + +### Wagmi Example + +```typescript +import { useEnsAddress } from "wagmi"; + +const { data: resolvedAddress } = useEnsAddress({ + name, + coinType: evmChainIdToCoinType(chain.id) +}); + +const { data: fallbackAddress } = useEnsAddress({ + name, + coinType: evmChainIdToCoinType(0), + enabled: !resolvedAddress +}); + +const address = resolvedAddress || fallbackAddress; +``` ## Copyright From 602baa6db22532371d6259f80160cf18e9b545da Mon Sep 17 00:00:00 2001 From: Luc Date: Tue, 1 Oct 2024 11:06:25 +0000 Subject: [PATCH 4/9] Update content --- ensips/x.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ensips/x.md b/ensips/x.md index 473c677..4093988 100644 --- a/ensips/x.md +++ b/ensips/x.md @@ -37,23 +37,22 @@ This is derived from `evmChainIdToCoinType(0)`, as per [ENSIP-11](./11). ### Proposed Implementation -- universal resolver magic -- example client implementation +There are multiple routes around implementing this; - +## Forwards Compatibility +Implementing this proposal following Appendix A allows for a smooth transition to the new functionality. +Later implementations can be reduced down to just a single eth call. ## Appendix A: Example Implementation From f1e2148ffe9f55cf9f40476923e07773e039d9d4 Mon Sep 17 00:00:00 2001 From: Luc van Kampen Date: Sun, 6 Oct 2024 07:11:54 +0200 Subject: [PATCH 5/9] Update x.md --- ensips/x.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ensips/x.md b/ensips/x.md index 4093988..6fe4b0e 100644 --- a/ensips/x.md +++ b/ensips/x.md @@ -13,6 +13,8 @@ ensip: This ENSIP specifies a way to set an EOA/Fallback address for a name. This allows for users to set one address to be used for all chains, or as a fallback for when a chain-specific address record is not set. +# testheader + ## Motivation With the rising interest and research around account abstraction, in addition to the maturation of the multi-chain ecosystem, there is a need for users to be able to set a single address to be used across all chains. From 293cd49c582be8b02687602d5aa9e6e300c45491 Mon Sep 17 00:00:00 2001 From: Luc van Kampen Date: Sun, 6 Oct 2024 07:15:46 +0200 Subject: [PATCH 6/9] Update x.md --- ensips/x.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/ensips/x.md b/ensips/x.md index 6fe4b0e..4093988 100644 --- a/ensips/x.md +++ b/ensips/x.md @@ -13,8 +13,6 @@ ensip: This ENSIP specifies a way to set an EOA/Fallback address for a name. This allows for users to set one address to be used for all chains, or as a fallback for when a chain-specific address record is not set. -# testheader - ## Motivation With the rising interest and research around account abstraction, in addition to the maturation of the multi-chain ecosystem, there is a need for users to be able to set a single address to be used across all chains. From 1aa746258f5684416284b3e1df99f4582c4f7c18 Mon Sep 17 00:00:00 2001 From: Luc Date: Thu, 24 Oct 2024 19:01:33 +0000 Subject: [PATCH 7/9] Expand on language & introduce public resolver modifications --- ensips/x.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ensips/x.md b/ensips/x.md index 4093988..764b0e2 100644 --- a/ensips/x.md +++ b/ensips/x.md @@ -17,9 +17,11 @@ This ENSIP specifies a way to set an EOA/Fallback address for a name. This allow With the rising interest and research around account abstraction, in addition to the maturation of the multi-chain ecosystem, there is a need for users to be able to set a single address to be used across all chains. -For a simple EOA user, this means setting their address once, and never having to worry about it again. +For a simple Externally Owned Account (EOA) user, this means setting their address once, and never having to worry about it again. For more advanced users, this means that chain-specific records can be used for smart-contract wallets, and an EOA can be specified as fallback. +This ENSIP introduces opt-in functionality that can be leveraged by both EOA and smart-contract wallets, and does not impact the existing functionality of ENS. + ## Specification This ENSIP aims to extend the functionality introduced in [ENSIP-9](./9) and [ENSIP-11](./11) and simply relies on the same functionality. @@ -28,12 +30,12 @@ This ENSIP aims to extend the functionality introduced in [ENSIP-9](./9) and [EN The standard CoinType for this proposed chain id is `2147483648`. -This is derived from `evmChainIdToCoinType(0)`, as per [ENSIP-11](./11). +This can be derived from `0x80000000 | 0` or `evmChainIdToCoinType(0)` , as per [ENSIP-11](./11). ### Resolution Order - first normal cointype lookup for the chain designated -- then lookup for eoa chain id +- then lookup for EOA Chain Id ### Proposed Implementation @@ -42,9 +44,16 @@ There are multiple routes around implementing this; For the short-term; we can already use this specification in our apps today (see Appendix A). Adoption of this method is encouraged as it is future-proof, and can be easily updated in the future. -For the smoothest implementation, we can leverage the universal resolver to handle this functionality for us. +For the smoothest implementation, we can leverage the public resolver to handle this functionality for us. This would mean no additional code is needed, and we can use the regular one-liners you are used to. +### Public Resolver + +The public resolver could choose to implement a fallback mechanism for EOA addresses. +Such that when a `coinType` lookup occurs, and the resolver does not find an address record, it will return the EOA address. + +This allows for additional flexibility allowing users to set a fallback address for all evm-compatible chains. + ## Backwards Compatibility This proposal is backwards compatible with the existing `addr(node, coinType)` functionality, and simply adds additional fallback behavior. From 6042bf589ed772be46a2e3b73d97bd5500e9c95f Mon Sep 17 00:00:00 2001 From: Luc Date: Thu, 24 Oct 2024 19:09:23 +0000 Subject: [PATCH 8/9] Improve resolution order --- ensips/x.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ensips/x.md b/ensips/x.md index 764b0e2..b6c9ebe 100644 --- a/ensips/x.md +++ b/ensips/x.md @@ -34,8 +34,12 @@ This can be derived from `0x80000000 | 0` or `evmChainIdToCoinType(0)` , as per ### Resolution Order -- first normal cointype lookup for the chain designated -- then lookup for EOA Chain Id +The resolution process remains as normal however now an extra lookup can be implemented client-side (or via proposed public resolver implementation). + +The initial lookup is done for the chainId the user is currently on / interested in. +For example for Optimism (EVM Chain Id 10), the initial lookup would be for `coinType = 0x80000000 | 10`. + +If the lookup does not result in an address, a second lookup is done for the EOA Chain Id. ### Proposed Implementation From c325c9f061917afd05ec91ea6c8a892e7c0ee398 Mon Sep 17 00:00:00 2001 From: Luc Date: Tue, 29 Oct 2024 11:20:37 +0000 Subject: [PATCH 9/9] Update to remove client-side implementation --- ensips/x.md | 57 +++-------------------------------------------------- 1 file changed, 3 insertions(+), 54 deletions(-) diff --git a/ensips/x.md b/ensips/x.md index b6c9ebe..f691402 100644 --- a/ensips/x.md +++ b/ensips/x.md @@ -43,18 +43,15 @@ If the lookup does not result in an address, a second lookup is done for the EOA ### Proposed Implementation -There are multiple routes around implementing this; +There are multiple routes we considered around implementing this; client-side, or via a public resolver implementation. -For the short-term; we can already use this specification in our apps today (see Appendix A). -Adoption of this method is encouraged as it is future-proof, and can be easily updated in the future. - -For the smoothest implementation, we can leverage the public resolver to handle this functionality for us. +For the smoothest implementation, leveraging the public resolver to handle this functionality for us seems ideal. This would mean no additional code is needed, and we can use the regular one-liners you are used to. ### Public Resolver The public resolver could choose to implement a fallback mechanism for EOA addresses. -Such that when a `coinType` lookup occurs, and the resolver does not find an address record, it will return the EOA address. +Such that when a `coinType` lookup occurs (for an EVM-compatible chain), and the resolver does not find an address record, it will return the EOA address. This allows for additional flexibility allowing users to set a fallback address for all evm-compatible chains. @@ -62,54 +59,6 @@ This allows for additional flexibility allowing users to set a fallback address This proposal is backwards compatible with the existing `addr(node, coinType)` functionality, and simply adds additional fallback behavior. -## Forwards Compatibility - -Implementing this proposal following Appendix A allows for a smooth transition to the new functionality. -Later implementations can be reduced down to just a single eth call. - -## Appendix A: Example Implementation - -Do note that the implementations below are the current implementations, and may change in the future. - -### Viem Example - -```typescript -import { getEnsAddress } from "viem/actions"; -import { mainnet, optimism } from "viem/chains"; -import { createPublicClient, http } from "viem"; -import { evmChainIdToCoinType } from '@ensdomains/address-encoder/utils'; - -const client = createPublicClient({ transport: http(), chain: mainnet }) - -const name = "luc.eth"; -const targetChain = optimism; - -// First lookup the targetChain address -const target_address = await getEnsAddress(client, { name, coinType: evmChainIdToCoinType(targetChain.id) }); - -// Then lookup the EOA address if needed -const address = target_address || await getEnsAddress(client, { name, coinType: evmChainIdToCoinType(0) }); -``` - -### Wagmi Example - -```typescript -import { useEnsAddress } from "wagmi"; - -const { data: resolvedAddress } = useEnsAddress({ - name, - coinType: evmChainIdToCoinType(chain.id) -}); - -const { data: fallbackAddress } = useEnsAddress({ - name, - coinType: evmChainIdToCoinType(0), - enabled: !resolvedAddress -}); - -const address = resolvedAddress || fallbackAddress; -``` - ## Copyright Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).