bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 4쪽
38910-pricing-fees) and a [temporary premium auction](https://support.ens.domains/en/articles/7900612-what-is-temporary-premium) upon expiration.
By default there is no character limit on subnames, but your contract could have its own rules and fee structure or whatever you want. For example, you can:
* Allow or disallow specific addresses from registering / renewing
* Only allow registration based on some custom criteria like holding a specific NFT
* Custom length restrictions like only 3+ characters or \< 100 characters
* Only allow names with characters `[a-z0-9]` and nothing else
* Use a custom fee structure based on:
* The length of the name
* The specific characters that are in the name, like emojis
* A pre-curated list of "good" names like people's first names
* And whatever other rules you want.
#### More information
See this page for a step-by-step guide on creating and setting up your own subname registrar: [Creating a Subname Registrar](/wrapper/creating-subname-registrar)
There is even a set of [reference implementation contracts](/wrapper/creating-subname-registrar#reference-implementation) you can use as a starting base!
### Give subnames out to NFT holders
#### I want to give subnames out to all of my DAO members / NFT holders!
Say you own the wrapped name `mycoolnft.eth`, representing a popular NFT project you created. You want to distribute subnames like `6529.mycoolnft.eth` to all holders.
One option is to just bulk create the subnames and drop the wrapped NFTs into their wallets. This might be good at least as an initial drop, because then the holders don't need to interact with any contract or spend any gas, you're doing that for them!
To create the subnames, you'd use the [setSubnodeOwner](https://github.com/ensdomains/ens-contracts/tree/master/contracts/wrapper#setsubnodeowner) or [setSubnodeRecord](https://github.com/ensdomains/ens-contracts/tree/master/contracts/wrapper#setsubnoderecord) methods.
You must also decide:
#### How much control over the subnames do you want to relinquish?
Do you want to be able to revoke subnames? Or do you want them to be completely outside your control?
One thing to consider is whether you want the **current** holder of your NFT to always be able to claim/reclaim the corresponding ENS subname. If so, then you will **not** want to Emancipate those subnames (in other words, do not burn **`PARENT_CANNOT_CONTROL`**).
If the subname is Emancipated, then the NFT holder could sell/transfer the NFT but keep the subname (up until the expiry).
To make it easy for anyone to claim/reclaim a subname after your initial drop, you can set up a contract for this.
#### Setting up a subname claim contract
The claim method of your contract could:
1. Call `ownerOf` or `balanceOf` on your NFT contract to get or verify the current owner of the NFT
2. Call `ownerOf` or `balanceOf` on the ENS Name Wrapper contract to get or verify the current owner of the wrapped subname
* If both owner addresses are the same, just return, nothing to do
3. Call `setSubnodeOwner` or `setSubnodeRecord` on the ENS Name Wrapper:
* **owner:** The current owner of the NFT
* **fuses:** What fuses you want to burn (if any) on that subname. If you burn any fuses, you must also set an expiry.
* **expiry:** When the subname will expire.
Then, to give that contract access to create subnames on your behalf, you would call `setApprovalForAll` on the Name Wrapper to approve your contract as an operator.
Now, even if the NFT gets sold / transferred, the new owner will be able to claim their `mycoolnft.eth` subname at any time.
In addition, if you expand your NFT collection in the future and there are new owners, then those new owners would be able to claim their subnames as well.
If you are creating a new NFT contract, you could even bake this functionality **directly into the NFT contract** too, instead of needing a separate contract! By doing this, you wouldn't need a separate `claim` method either, your NFT contract would just **automatically transfer the wrapped ENS subname** whenever the NFT itself gets transferred!
#### Giving your subname owners perks
If you decide to not Emancipate the subnames that you issue, you *will* still be able to burn any Parent-Controlled Fuses. There are 13 unreserved parent-controlled fuses that you can use however you wish!
For example, perhaps you want to grant onchain "perks" or "roles" to certain holders. You would call [setChildFuses](https://github.com/ensdomains/ens-contracts/tree/master/contracts/wrapper#setchildfuses) on the Name Wrapper and pass in the fuses you want to burn, and the expiry.
This means that those "perks" or "roles" can also be time-boxed if you want. Maybe a perk expires in 1 week or something, up to you.
There is also the reserved **`CAN_EXTEND_EXPIRY`** parent-controlled fuse. If you burn this, then the subname owner will be able to extend their own expiry whenever they want.
import { EnsProfile } from '../../components/EnsProfile'
import { Card } from '../../components/ui/Card'
## Avatars
Personalization of profiles is what makes identity great.
This page covers the very special **avatar** record that enables users to take their avatar with them across the web.
<Card className="flex justify-center">
<EnsProfile name="nick.eth" hideAddress />
</Card>
### Getting the user's Avatar
Avatars are an awesome way for users to express themselves. To get the user's avatar, all you need is their **name**. If you only have their address, see [primary names](/web/reverse#get).
The following code snippets let you get the avatar for a user.
:::code-group
```tsx [Wagmi]
// https://wagmi.sh/react/hooks/useEnsAvatar
import { useEnsAvatar } from 'wagmi'
function App() {
const { data: ensAvatar } = useEnsAvatar({
address: 'nick.eth',
chainId: 1, // (1 = Ethereum Mainnet, 11155111 = Sepolia)
})
return (
<img
src={ensAvatar || 'https://avatars.jakerunzer.com/nick.eth'}
alt="nick.eth"
/>
)
}
```
```ts [Ethers]
// https://docs.ethers.org/v5/api/providers/provider/#Provider-getAvatar
const ensAvatar = await provider.getAvatar('nick.eth')
```
```ts [Viem]
// https://viem.sh/docs/ens/actions/getEnsAvatar.html
import { normalize } from 'viem/ens'
import { publicClient } from './client'
const ensAvatar = await publicClient.getEnsAvatar({
name: normalize('nick.eth'),
})
```
```py [Web3.py]
# https://web3py.readthedocs.io/en/latest/ens_overview.html#read-text-metadata-for-an-ens-record
from ens.auto import ns
avatar = ns.get_text('alice.eth', 'avatar')
```
:::
#### The Metadata Service
The [metadata service](https://metadata.ens.domains/docs) is run by ENS Labs. It is a free service web service that allows you to retrieve the
avatar of an ENS name via a web request, as opposed to adding extra logic to your application and interacting
with an ethereum node. This is of course centralised and should be used if absolutely necessary.
### What exactly is an Avatar Record?
An avatar record is simply a [text record](/web/records) that has "avatar" as its key and a URI as its value,
with some rules about what URI schemes are supported and how to process them. For more info, see [ENSIP-11](/ensip/12).
### Supported URI schemes
Clients are expected to support a number of URI schemas, which aren't always web URIs, so the final result you see in your application
will vary depending on how the library you are using has decided to handle avatar records.
* `http(s):` - URI Scheme for HTTP(S) URLs. Libraries will most likely return the result directly.
* `ipfs:` - URI scheme for [IPFS hashes](). Libraries may decide to fetch the result from a public gateway for you.
* `data:` - URI Scheme for [data URIs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs).
Libraries will most likely return the result directly.
* `eip155:` - The URI scheme for EIP-155 identifiers for linking to NFTs on Ethereum based chains. A little complicated
to resolve manually, most libraries should resolve this for you and return the underlying resource.
:::note
For EIP-155 NFT Avatars the nft must be owned by the wallet address the ENS
name resolves to. This is done by checking the `ownerOf` method on the NFT
contract.
:::
### Common schemes that aren't officially supported
* `ethereum:` - The URI scheme for Ethereum addresses
* `bzz:` - The URI scheme for Swarm hashes
### File Information
Avatars come in many different shapes and sizes. Not just the above URI schemas, but also in different file formats, sizes, and more.
Although standards exist for some of these, files are **not required** to follow these standards.
Below is some information about the avatars your app might be loading.
| FileProperty: | Info/Recommendation |
| -------------- | ------------------------------------------------------------------------------- |
| File Extension | Mostly `png`, `jpeg`, `jpg`, `webp`, `gif`, `webm`, but could be anything |
| File Size | We recommend having sensible timeouts |
| Aspect Ratio | We recommend `object-fit: cover` or setting a background color |
| Transparency | We recommend setting a background color as some images may contain transparency |
Luckily most browsers and network libraries have default timeouts to start with, we highly recommend that if you are doing any manual avatar downloading or fetching you add a sensible timeout.
import { EnsProfile } from '../../components/EnsProfile'
import { SendTransactionDemo } from '../../components/SendTransaction'
import { Card } from '../../components/ui/Card'
## Design Guidelines \[Guidelines for designing interfaces that use ENS names]
ENS is a tool to simplify the experience for your users by making blockchain addresses human-readable.
Here are a series of guidelines and tools that will help you make good design choices and better implement ENS in your product.
### When to show ENS names
In every instance where a user might otherwise see an Ethereum address, you can instead display an ENS name (with its avatar, if relevant).
This is true for both read and write operations.
An example of read operations where it's appropriate to show an ENS name is the connected wallet status or representing an action from another user like a vote ([Snapshot is a great example](https://snapshot.box/)).
<Card className="flex justify-center">
<EnsProfile name="nick.eth" />
</Card>
An example of write operations where it's appropriate to show an ENS name is when a user is inputting an address of any kind (token transfer, smart contract interaction, etc.).
<Card>
<SendTransactionDemo />
</Card>
<div id="send_transaction" />
Beyond these use cases, remember that the [ENS Public Resolver](/resolvers/public) allows you to link [different kinds of resources](/web/records) to ENS names.
### 1. Replacing Ethereum addresses with ENS Names
:::note
An ENS name should only be shown in place of an Ethereum address if the user has set a reverse record for their address, and if the reverse record matches the forward resolution. [Learn more about primary names](/web/reverse).
:::
#### 1.1 - Displaying ENS names instead of Ethereum addresses
{/* TODO: build a sample UI of ENS names in a list, like votes or messages or transfers */}
When replacing Ethereum addresses with ENS names you should consider these facts and best practices:
* **Design a truncated version of the ENS name:** ENS names can be very long; besides not being character-limited, users can create an infinite number of nested subdomains.
If you do show a truncated version of the name, you should provide a way to view the full name, such as expanding it on hover.
* **Not all ENS names end with .eth**: ENS supports [.eth](/registry/eth) and most DNS TLDs such as [.com, .xyz, and 1200+ others](/dns/tlds).
A correct implementation of ENS treats any dot-separated name as a potential ENS name and will attempt a look-up.
#### 1.2 - Always provide an option to see the Ethereum address associated with the ENS name
If you are showing the ENS name in its entirety or a truncated version, you should:
* **Always provide the user a way to display the full Ethereum address**: Notice how if you type "ens.eth" in the [example above](#send_transaction), the resolved ETH address appears under the name.
This is especially important in high-risk situations, such as when the user is about to send a transaction or interact with a smart contract.
* **Allow the user to copy the full Ethereum address**: Allow the user to copy the full address either through a copy button or by selecting it.
* **Optionally give the user a way to automatically open the Ethereum address in a block explorer** such as Etherscan.
* **Optionally show the** **balance amount of signed-in users.** User research shows that users tend to recognise their own Ethereum address through their balance, as well as the address itself.
This is meant only for the currently "signed in" user: only show their own balance and avoid showing the balance of other users.
### 2. Resolving input fields
{/* <LiveDemo id="send_transaction" /> */}
Input fields where a user is supposed to insert Ethereum addresses should also accept and resolve ENS names. These inputs indicate that the user wants to interact with another user's Ethereum address or contract.
Follow these guidelines to create the best experience:
* **Wait before resolving the ENS name**: Debounce input fields that accept ENS names to avoid unnecessary network calls. You can also wait for the user to type a minimum of 1 character on both sides of the dot before resolving the name. For example, if the user type "ens.", there is no chance of it being a valid ENS name and therefore no need to resolve it. But after the user types "ens.e", it should be treated as a potential ENS name.
* **Don't overwrite the input field with the Ethereum address:** Show the resolved ENS name near the input field instead.
* **Always display both the ENS name** ***and*** **the Ethereum address together** : Do this after it has successfully been resolved.
### Other guidelines and tips
#### Usernames for accounts that don't have an ENS name
You can offer free ENS names to your users which would not only improve their experience in your application, but also across the Ethereum ecosystem.
See [how to issue subdomains](/web/subdomains).
#### Caching and updating ENS Names
If your application needs to display many ENS Names in the UI, you can consider **caching** (for a short period of time) the ENS Name after it has been resolved or after the user has added the name in an input field.
Your **optimistic UI** can display the names from cache **in non-risky situations**, in which your user for example is simply browsing, but doesn't need to act or make decisions based on the information displayed.
However, **in all risky situations** (eg transferring anything of value or interacting with a smart contract), you should **perform a direct live resolution** and get the most up to date information from the ENS Registry.
Also consider that users can change their information at any time which may not be tracked in the onchain registry, so you should **periodically validate the information you cached**. [Learn more about offchain ENS names](/learn/ccip-read).
#### Notes on displaying Ethereum Addresses (with or without ENS names)
Even when ENS names are not available, [research](https://medium.com/@lyricalpolymath/web3designdecisionframework-e84075816515) [shows](https://medium.com/@lyricalpolymath/web3-design-principles-f21db2f240c1) that there are some good practices to follow when displaying Ethereum addresses in dApps.
* **Always show the initial ' 0x '** to indicate it's an address.
* When displaying the name in shorthand versions, **show the first 5 and last 4 characters of the address**.
This is not a security requirement as vanity addresses can be spoofed relatively simply; this is a good practice because some users check the beginning of the name and others check the end of the name.
Also, four is the highest number of elements that our mind can easily chunk, parse and remember well.
* **Always provide a way to display the full Ethereum address.**
### Front-end tools
[Thorin](https://thorin.ens.domains/) is a react component library for the ENS design system.
It provides a set of components that make it easier to follow the guidelines and best practices described above.
## Preparing for ENSv2 \[Everything you need to know to prepare your application for ENSv2.]
ENSv2 introduces a redesigned architecture and improved multi-chain interoperability. To ensure your application works seamlessly with ENSv2, you'll need to make a few key updates.
The good news? For most applications, preparing for ENSv2 is as simple as updating to the latest version of a [supported library](/web/libraries). At the time of writing, not all libraries have added ENSv2 support yet. Here's the current status:
* **viem:** [>= v2.35.0](https://github.com/wevm/viem/blob/main/src/CHANGELOG.md#2350).
* **ethers:** [>= v6.17.0](https://github.com/ethers-io/ethers.js/releases/tag/v6.17.0) or use the [ENS ethers patch](https://github.com/ensdomains/ethers-patch).
* **web3.py:** [>= v7.16.0](https://web3py.readthedocs.io/en/stable/release_notes.html#web3-py-v7-16-0-2026-05-01).
* **ENSjs:** [>= v4.2.3](https://github.com/ensdomains/ensjs/releases/tag/%40ensdomains%2Fensjs%404.2.3).
* **web3j:** [>= v5.0.3](https://central.sonatype.com/artifact/org.web3j/core?smo=true).
* **go-ens:** [>= v4.0.0](https://github.com/ensdomains/go-ens).
* **alloy-rs:** [>= v2.4.2](https://github.com/alloy-rs/alloy/releases/tag/v2.4.2).
* **web3.js:** Deprecated.
:::info
**If your application only reads ENS data, you're done!** Everything is handled automatically by a supported library.
* If your application also writes to ENS, see [If Your Application Writes to ENS](#if-your-application-writes-to-ens).
* If your application indexes ENS data, see [Indexing ENSv2](/ensv2/indexing).
The sections below are optional reading for those who want to understand the technical details or test their integration manually.
:::
### Universal Resolver
Even though ENSv2 is designed for multi-chain, all resolution still starts on Ethereum Mainnet. There is a [new Universal Resolver](/resolvers/universal) that acts as the canonical entry point. This is an upgradable proxy contract, owned be the ENS DAO, so its address won't change in the future if its implementation is changed.
Your application needs to use this new Universal Resolver in order to be ready for ENSv2. As mentioned above, updating to the latest version of your supported web3 library handles this automatically.
Learn more about the [Universal Resolver here](/resolvers/universal) and about the [resolution process in general here](/resolution).
#### Testing Universal Resolver Support
To test if your integration uses the Universal Resolver, try resolving the address for `ur.integration-tests.eth`. It should return `0x2222222222222222222222222222222222222222`. If it instead returns `0x1111111111111111111111111111111111111111`, you likely need to update your web3 library.
### Offchain and L2 Resolution with CCIP Read
ENSv1 already supports delegating resolution from Ethereum Mainnet to an L2 or completely offchain using [CCIP Read (ERC-3668)](/learn/ccip-read). All the libraries mentioned above implement CCIP Read. However, not all integrations handle it properly.
In a nutshell, CCIP Read defers resolution to a gateway. Think of a gateway as an HTTP API. The response of the gateway can be verified with a read-call to the ENS contracts on Ethereum Mainnet (or Sepolia for testing). This means that your application needs to be able to send HTTP requests as part of the ENS resolution process. As mentioned above, this is already handled by the web3 libraries in the background.
Learn more about [CCIP-Read, Offchain and L2 resolvers here](/resolvers/ccip-r프로젝트로 돌아가기