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