Skip to content
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

Clarify EVM coin types/encoding, add page description #226

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Changes from all commits
Commits
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
81 changes: 43 additions & 38 deletions docs/web/resolution.mdx
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -95,31 +96,31 @@ 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' }}
Expand All @@ -137,9 +138,10 @@ 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).

Expand Down Expand Up @@ -172,14 +174,17 @@ const btcAddress = await resolver?.getAddress(0);

</CodeGroup>

| 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 |

<div className="w-full flex items-center justify-center gap-1">
... and many many more following
Expand All @@ -189,7 +194,7 @@ const btcAddress = await resolver?.getAddress(0);

### 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

Expand Down
Loading