From 5b46405a06b1e4bb4c0efed5c2efb9d8cc8eb3c1 Mon Sep 17 00:00:00 2001
From: Greg Skriloff <35093316+gskril@users.noreply.github.com>
Date: Mon, 15 Apr 2024 15:11:30 -0400
Subject: [PATCH 1/3] Clarify EVM coin types/encoding, add description
---
docs/web/resolution.mdx | 122 +++++++++++++++++++++-------------------
1 file changed, 64 insertions(+), 58 deletions(-)
diff --git a/docs/web/resolution.mdx b/docs/web/resolution.mdx
index c2892abaa..b7902f6f2 100644
--- a/docs/web/resolution.mdx
+++ b/docs/web/resolution.mdx
@@ -1,13 +1,14 @@
{/* * @type {import('@/lib/mdxPageProps').MdxMetaProps} */}
export const meta = {
- description: '',
- emoji: '🔍',
- contributors: [
- 'lucemans'
- ]
+description: 'Learn how to resolve blockchain addresses from human-readable names with ENS.',
+emoji: '🔍',
+contributors: [
+'lucemans',
+'gskril'
+]
};
-# Lookup Address
+# Address Lookup
The ENS Protocol aims to make it easy to use Ethereum.
It does this by providing a simple way to use human-readable names instead of long machine-readable addresses.
@@ -17,9 +18,9 @@ It does this by providing a simple way to use human-readable names instead of lo
The goal here is to take a name, such as `nick.eth`, and convert it to an address, such as `0x225f137127d9067788314bc7fcc1f36746a3c3B5`.
- luc.eth
- ➡️
- 0x225...c3B5
+ luc.eth
+ ➡️
+ 0x225...c3B5
The simplest thing you can do is start with a name, and resolve it to an address.
@@ -29,29 +30,29 @@ Think of places where users can enter names, such as sending transactions, chatt
```tsx {{ title: 'Wagmi (React)', language: 'tsx', meta: 'focus=4:9', variant: 'wagmi', link: 'https://wagmi.sh/react/hooks/useEnsAddress', stackblitz: 'https://stackblitz.com/edit/ens-wagmi-use-ens-address' }}
-import { useAccount, useEnsName, useEnsAvatar } from "wagmi";
+import { useAccount, useEnsName, useEnsAvatar } from 'wagmi'
export const Name = () => {
- const { data: ensName } = useEnsAddress({
- address: "luc.eth", // The name to lookup
- chainId: 1, // The chainId to lookup on
- });
+ const { data: ensName } = useEnsAddress({
+ address: 'luc.eth', // The name to lookup
+ chainId: 1, // The chainId to lookup on
+ })
- return {ensName || address}
;
-};
+ return {ensName || address}
+}
```
```ts {{ title: 'Ethers.js (TS)', variant: 'ethers-v5' }}
-const address = await provider.lookupAddress("luc.eth");
+const address = await provider.lookupAddress('luc.eth')
```
```ts {{ title: 'Viem (TS)', variant: 'viem', link: 'https://viem.sh/docs/ens/actions/getEnsAddress.html', stackblitz: 'https://stackblitz.com/edit/ens-viem-get-ens-address' }}
-import { normalize } from "viem/ens";
-import { publicClient } from "./client";
+import { normalize } from 'viem/ens'
+import { publicClient } from './client'
const ensAddress = await publicClient.getEnsAddress({
- name: normalize("luc.eth"),
-});
+ name: normalize('luc.eth'),
+})
```
```rust {{ variant: 'ethers-rs' }}
@@ -83,15 +84,15 @@ func main() {
```ts {{ title: 'Alchemy', variant: 'alchemy-sdk', link: "https://docs.alchemy.com/docs/how-to-resolve-ewallet-given-ens" }}
// Setup: npm install alchemy-sdk
-import { Alchemy, Network } from "alchemy-sdk";
+import { Alchemy, Network } from 'alchemy-sdk'
const config = {
- apiKey: "<-- ALCHEMY APP API KEY -->",
- network: Network.ETH_MAINNET,
-};
-const alchemy = new Alchemy(config);
+ apiKey: '<-- ALCHEMY APP API KEY -->',
+ network: Network.ETH_MAINNET,
+}
+const alchemy = new Alchemy(config)
-alchemy.core.resolveName("vitalik.eth").then(console.log);
+alchemy.core.resolveName('vitalik.eth').then(console.log)
```
```ts {{ variant: 'ensjs', link: 'https://github.com/ensdomains/ensjs-v3/blob/feat/viem/docs/basics/fetching-a-profile.md' }}
@@ -137,65 +138,70 @@ To learn what happens under the hood when you do a forward lookup, read the [res
## Multi-Chain Addresses (BTC, LTC, etc) {{ navtitle: 'Multi-Chain Addresses', label: 'Multi-Chain', id: 'multi-chain', tag: '', }}
-ENS Names aren't just limited to storing Ethereum Addresses,
-Names can be queried with any [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) coin type,
-meaning you can also get addresses such as BTC, LTC. In addition to the above, Ethereum Chain specific addresses can also be queried using [ENSIP-11](/ensip/11).
+ENS Names aren't just limited to storing Ethereum addresses.
+Any blockchain address (BTC, LTC, SOL, etc.) can be queried by [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) coin type or a value derived from an EVM Chain ID (specified in [ENSIP-11](/ensip/11)). This includes Ethereum L2 networks such as OP Mainnet and Base.
+
+For EVM Chains, always use its [ENSIP-11](/ensip/11) coin type, irrespective of being included in SLIP-0044 (like Ether Classic).
The standardization of multichain addresses was first introduced in [ENSIP-9](/ensip/9), and also [EIP-2304](https://eips.ethereum.org/EIPS/eip-2304).
```tsx {{ title: 'Wagmi (React)', language: 'tsx', meta: 'focus=4:9', variant: 'wagmi' }}
-import { useEnsMultichainAddress } from "ens-tools/react";
+import { useEnsMultichainAddress } from 'ens-tools/react'
export const BitcoinAddress = () => {
- const { address: btcAddress, chainId } = useEnsMultichainAddress({
- name: "luc.eth",
- coinType: 0, // BTC
- });
+ const { address: btcAddress, chainId } = useEnsMultichainAddress({
+ name: 'luc.eth',
+ coinType: 0, // BTC
+ })
- return BTC: {btcAddress}
;
-};
+ return BTC: {btcAddress}
+}
```
```ts {{ title: 'Viem (TS)', variant: 'viem', link: 'https://viem.sh/docs/ens/actions/getEnsAddress.html#cointype-optional', stackblitz: 'https://stackblitz.com/edit/ens-viem-get-ens-address' }}
const ensName = await publicClient.getEnsAddress({
- name: normalize("wagmi-dev.eth"),
- coinType: 0, // BTC
-});
+ name: normalize('wagmi-dev.eth'),
+ coinType: 0, // BTC
+})
```
```ts {{ title: 'Ethers.js (TS)', variant: 'ethers-v5', link: 'https://docs.ethers.org/v5/api/providers/provider/#EnsResolver' }}
-const resolver = await provider.getResolver("luc.eth");
-const btcAddress = await resolver?.getAddress(0);
+const resolver = await provider.getResolver('luc.eth')
+const btcAddress = await resolver?.getAddress(0)
```
-| Chain / Network | ID |
-| --------------- | --- |
-| BTC | 0 |
-| LTC | 2 |
-| DOGE | 3 |
-| Solana | 501 |
-| Optimism | 614 |
-| Polygon (Matic) | 966 |
+| Network | Coin Type |
+| ------------ | ---------- |
+| Bitcoin | 0 |
+| Litecoin | 2 |
+| Dogecoin | 3 |
+| Ethereum | 60 |
+| Solana | 501 |
+| OP Mainnet | 2147483658 |
+| Polygon | 2147483785 |
+| Base | 2147492101 |
+| Arbitrum One | 2147525809 |
- ... and many many more following
- [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md)
- and [ENSIP-11](/ensip/11)
+ ... and many many more following
+ [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) and
+ [ENSIP-11](/ensip/11)
### Decoding Address Hashes
-Most libraries provide address decoding, however if you are reading these records raw values and would like to decode them to their multicoin appropriate address format, we recommend you read [ENSIP-9](/ensip/9), [EIP-2304](https://eips.ethereum.org/EIPS/eip-2304), and [ENSIP-11](/ensip/11).
+ENS resolvers store all addresses in bytes, which may have to be encoded to their respective address formats. To do this, we recommend using the [@ensdomains/address-encoder](https://www.npmjs.com/package/@ensdomains/address-encoder) package.
## Advanced
+```
From b5705ff4762dc25d56876010a9d430ddcf9cc379 Mon Sep 17 00:00:00 2001
From: Greg Skriloff <35093316+gskril@users.noreply.github.com>
Date: Mon, 15 Apr 2024 15:32:26 -0400
Subject: [PATCH 2/3] Try to match formatting
See https://github.com/ensdomains/docs/issues/227
---
docs/web/resolution.mdx | 120 ++++++++++++++++++++--------------------
1 file changed, 60 insertions(+), 60 deletions(-)
diff --git a/docs/web/resolution.mdx b/docs/web/resolution.mdx
index b7902f6f2..5a9b20aea 100644
--- a/docs/web/resolution.mdx
+++ b/docs/web/resolution.mdx
@@ -18,9 +18,9 @@ It does this by providing a simple way to use human-readable names instead of lo
The goal here is to take a name, such as `nick.eth`, and convert it to an address, such as `0x225f137127d9067788314bc7fcc1f36746a3c3B5`.
- luc.eth
- ➡️
- 0x225...c3B5
+ luc.eth
+ ➡️
+ 0x225...c3B5
The simplest thing you can do is start with a name, and resolve it to an address.
@@ -30,29 +30,29 @@ Think of places where users can enter names, such as sending transactions, chatt
```tsx {{ title: 'Wagmi (React)', language: 'tsx', meta: 'focus=4:9', variant: 'wagmi', link: 'https://wagmi.sh/react/hooks/useEnsAddress', stackblitz: 'https://stackblitz.com/edit/ens-wagmi-use-ens-address' }}
-import { useAccount, useEnsName, useEnsAvatar } from 'wagmi'
+import { useAccount, useEnsName, useEnsAvatar } from "wagmi";
export const Name = () => {
- const { data: ensName } = useEnsAddress({
- address: 'luc.eth', // The name to lookup
- chainId: 1, // The chainId to lookup on
- })
+ const { data: ensName } = useEnsAddress({
+ address: "luc.eth", // The name to lookup
+ chainId: 1, // The chainId to lookup on
+ });
- return {ensName || address}
-}
+ return {ensName || address}
;
+};
```
```ts {{ title: 'Ethers.js (TS)', variant: 'ethers-v5' }}
-const address = await provider.lookupAddress('luc.eth')
+const address = await provider.lookupAddress("luc.eth");
```
```ts {{ title: 'Viem (TS)', variant: 'viem', link: 'https://viem.sh/docs/ens/actions/getEnsAddress.html', stackblitz: 'https://stackblitz.com/edit/ens-viem-get-ens-address' }}
-import { normalize } from 'viem/ens'
-import { publicClient } from './client'
+import { normalize } from "viem/ens";
+import { publicClient } from "./client";
const ensAddress = await publicClient.getEnsAddress({
- name: normalize('luc.eth'),
-})
+ name: normalize("luc.eth"),
+});
```
```rust {{ variant: 'ethers-rs' }}
@@ -84,43 +84,43 @@ func main() {
```ts {{ title: 'Alchemy', variant: 'alchemy-sdk', link: "https://docs.alchemy.com/docs/how-to-resolve-ewallet-given-ens" }}
// Setup: npm install alchemy-sdk
-import { Alchemy, Network } from 'alchemy-sdk'
+import { Alchemy, Network } from "alchemy-sdk";
const config = {
- apiKey: '<-- ALCHEMY APP API KEY -->',
- network: Network.ETH_MAINNET,
-}
-const alchemy = new Alchemy(config)
+ apiKey: "<-- ALCHEMY APP API KEY -->",
+ network: Network.ETH_MAINNET,
+};
+const alchemy = new Alchemy(config);
-alchemy.core.resolveName('vitalik.eth').then(console.log)
+alchemy.core.resolveName("vitalik.eth").then(console.log);
```
```ts {{ variant: 'ensjs', link: 'https://github.com/ensdomains/ensjs-v3/blob/feat/viem/docs/basics/fetching-a-profile.md' }}
-import { http } from 'viem'
-import { mainnet } from 'viem/chains'
-import { createEnsPublicClient } from '@ensdomains/ensjs'
+import { http } from "viem";
+import { mainnet } from "viem/chains";
+import { createEnsPublicClient } from "@ensdomains/ensjs";
const client = createEnsPublicClient({
- chain: mainnet,
- transport: http(),
-})
+ chain: mainnet,
+ transport: http(),
+});
-const subgraphRecords = client.getSubgraphRecords({ name: 'ens.eth' })
+const subgraphRecords = client.getSubgraphRecords({ name: "ens.eth" });
const records = client.getRecords({
- name: 'ens.eth',
- records: {
- coins: [...(subgraphRecords?.coins || []), 'BTC', 'ETH', 'ETC', 'SOL'],
- texts: [
- ...(subgraphRecords?.texts || []),
- 'avatar',
- 'email',
- 'description',
- ],
- contentHash: true,
- abi: true,
- },
-})
+ name: "ens.eth",
+ records: {
+ coins: [...(subgraphRecords?.coins || []), "BTC", "ETH", "ETC", "SOL"],
+ texts: [
+ ...(subgraphRecords?.texts || []),
+ "avatar",
+ "email",
+ "description",
+ ],
+ contentHash: true,
+ abi: true,
+ },
+});
```
```python {{ variant: 'web3py' }}
@@ -148,28 +148,28 @@ The standardization of multichain addresses was first introduced in [ENSIP-9](/e
```tsx {{ title: 'Wagmi (React)', language: 'tsx', meta: 'focus=4:9', variant: 'wagmi' }}
-import { useEnsMultichainAddress } from 'ens-tools/react'
+import { useEnsMultichainAddress } from "ens-tools/react";
export const BitcoinAddress = () => {
- const { address: btcAddress, chainId } = useEnsMultichainAddress({
- name: 'luc.eth',
- coinType: 0, // BTC
- })
+ const { address: btcAddress, chainId } = useEnsMultichainAddress({
+ name: "luc.eth",
+ coinType: 0, // BTC
+ });
- return BTC: {btcAddress}
-}
+ return BTC: {btcAddress}
;
+};
```
```ts {{ title: 'Viem (TS)', variant: 'viem', link: 'https://viem.sh/docs/ens/actions/getEnsAddress.html#cointype-optional', stackblitz: 'https://stackblitz.com/edit/ens-viem-get-ens-address' }}
const ensName = await publicClient.getEnsAddress({
- name: normalize('wagmi-dev.eth'),
- coinType: 0, // BTC
-})
+ name: normalize("wagmi-dev.eth"),
+ coinType: 0, // BTC
+});
```
```ts {{ title: 'Ethers.js (TS)', variant: 'ethers-v5', link: 'https://docs.ethers.org/v5/api/providers/provider/#EnsResolver' }}
-const resolver = await provider.getResolver('luc.eth')
-const btcAddress = await resolver?.getAddress(0)
+const resolver = await provider.getResolver("luc.eth");
+const btcAddress = await resolver?.getAddress(0);
```
@@ -187,9 +187,9 @@ const btcAddress = await resolver?.getAddress(0)
| Arbitrum One | 2147525809 |
- ... and many many more following
- [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) and
- [ENSIP-11](/ensip/11)
+ ... and many many more following
+ [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md)
+ and [ENSIP-11](/ensip/11)
### Decoding Address Hashes
@@ -199,9 +199,9 @@ ENS resolvers store all addresses in bytes, which may have to be encoded to thei
## Advanced
```
From 10eb1053fc2da789d668c54f74b3d72685ed585a Mon Sep 17 00:00:00 2001
From: Greg Skriloff <35093316+gskril@users.noreply.github.com>
Date: Mon, 15 Apr 2024 15:59:27 -0400
Subject: [PATCH 3/3] Fix build error (I think)
---
docs/web/resolution.mdx | 1 -
1 file changed, 1 deletion(-)
diff --git a/docs/web/resolution.mdx b/docs/web/resolution.mdx
index 5a9b20aea..2c767f61c 100644
--- a/docs/web/resolution.mdx
+++ b/docs/web/resolution.mdx
@@ -204,4 +204,3 @@ ENS resolvers store all addresses in bytes, which may have to be encoded to thei
tag="Advanced"
description="To learn more about the resolution process, please read the Resolution section."
/>
-```