Ethereum Name Service 백서

Ethereum Name Service

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 11쪽

contracts called <b>registrars</b>, which specify rules governing the allocation of their names. Anyone may, by following the rules imposed by these registrar contracts, obtain ownership of a domain for their own use. | TLD | Registrar Contract | | ------------------- | -------------------------------------- | | `[root]` | [The Registry](/registry/ens) | | `.eth` | [ETH Registry](/registry/eth) | | `.com`, `.xyz`, etc | [DNS Registrar](/registry/dns) | | `.addr.reverse` | [Reverse Registrar](/registry/reverse) | ### Who owns the root Registry? The [ENS Registry](https://etherscan.io/address/0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e) is owned by the [ENS Root](https://etherscan.io/address/0xaB528d626EC275E3faD363fF1393A41F581c5897) which is owned by the [ENS DAO Wallet](https://etherscan.io/address/0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7). To verify this you can run the `owner` function on the registry & root contracts. ### Other Functions ```ts // Get Owner ENS.owner(bytes32 node) view returns (address) // Get Resolver ENS.resolver(bytes32 node) view returns (address) // Get TTL ENS.ttl(bytes32 node) view returns (uint64) // Get Approval ENS.isApprovedForAll(address owner, address operator) view returns (bool) // Check Record Existence ENS.recordExists(bytes32 node) view returns (bool) ``` ```ts // Set Owner (only callable by current owner) ENS.setOwner(bytes32 node, address owner) // Set Resolver ENS.setResolver(bytes32 node, address resolver) // Set TTL ENS.setTTL(bytes32 node, uint64 ttl) // Set Subnode Owner ENS.setSubnodeOwner(bytes32 node, bytes32 label, address owner) // Set Multiple (convenience function (setResolver, setTTL, setOwner)) ENS.setRecord(bytes32 node, address owner, address resolver, uint64 ttl) // Set Multiple Subnode ENS.setSubnodeRecord(bytes32 node, bytes32 label, address owner, address resolver, uint64 ttl) // Set Approval ENS.setApprovalForAll(address operator, bool approved) ``` Events ```ts // Transfer Event event Transfer(bytes32 indexed node, address owner) // New Resolver Event event NewResolver(bytes32 indexed node, address resolver) // New TTL Event event NewTTL(bytes32 indexed node, uint64 ttl) // New Owner Event event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner) ``` import { FiBookOpen, FiClock, FiHash } from 'react-icons/fi' import { Card } from '../../components/ui/Card' ## ETH Registrar \[Smart contracts responsible for the ".eth" TLD] The ETH Registrar is a special registrar. It allows for trustless onchain name registration and is in charge of the ".eth" TLD. ### BaseRegistrar vs Controller The ETH Registrar is split into two contracts. The [BaseRegistrar](https://github.com/ensdomains/ens-contracts/blob/staging/contracts/ethregistrar/BaseRegistrarImplementation.sol) and the [ETHRegistrarController](https://github.com/ensdomains/ens-contracts/blob/staging/contracts/ethregistrar/ETHRegistrarController.sol). The BaseRegistrar is responsible for name ownership, transfers, etc (ownership related), while the Controller is responsible for registration & renewal (pricing related). This separation is done to reduce the attack surface of the registrar, and provides users with the guarantees of continued ownership of a name so long as the registrar is in place. #### Controllers The [ETHRegistrarController](https://github.com/ensdomains/ens-contracts/blob/staging/contracts/ethregistrar/ETHRegistrarController.sol) is the main controller for the ETH Registrar, and provides a straightforward registration and renewal mechanism. ### Pricing Structure The ETH Registrar charges a fee for registration. This fee is paid in ETH and is set to prevent spamming the registrar. Any protocol fees are sent to the ENS Treasury. #### Pricing Oracle Initially, a single pricing oracle was deployed, the [StablePriceOracle](https://github.com/ensdomains/ens-contracts/blob/master/contracts/ethregistrar/StablePriceOracle.sol). This contract has owner-set prices for each name length (1, 2, 3, 4, 5 or more). Users do not have to interact with this oracle directly, as the controller provides functionality to determine the pricing for a registration or renewal. #### 3, 4, and 5 Letter Names The ETH Registrar has special pricing for 3, 4, and 5 (and more) letter names. At the time of writing, a `5+` letter `.eth` will cost you `5 USD` per year. A `4` letter `160 USD` per year, and a `3` letter `640 USD` per year. This pricing structure is done to promote market diversity as there are an exponentially less amount of names the shorter they become. The minimum length of a name is 3 characters. | Name Length | Price (USD) | | ----------- | ----------- | | 5+ | 5 | | 4 | 160 | | 3 | 640 | #### Premium & Auctions In addition to length-based pricing the ETH Registrar also has a premium pricing structure. 90 days after a name expires (aka after the grace period), the name will go into a Temporary Premium Auction. The Auction is a 21 day dutch auction, meaning that the price starts high (\~100 Million USD) and exponentially decrease till it hits 0 or a bid goes through. This is done to prevent sniping of names, and ensures the name goes to the highest bidder fairly. <Card> <div className="mx-auto h-32"> <svg className="h-full w-full" width="160" height="90" viewBox="0 0 160 90"> <path d="M 10 10 Q 10 80 150 80" stroke="#3889FF" fill="transparent" /> </svg> </div> </Card> You can read more about the temporary premium in [this article](https://support.ens.domains/en/articles/7900612-what-is-temporary-premium). #### Where does the money go? Upon registration funds are sent to the ETHRegistrarController. The controller then sends the funds to the ENS Treasury (anyone can call the `withdraw` method to trigger this). Income from the ETH Registrar is used to fund the development of ENS, its ecosystem, and other public goods. Read more about our spending in [Article III of the Constitution](/dao/constitution#iii-income-funds-ens-and-other-public-goods). ### ERC721 and NFTs In the early days of ENS, the ERC721 standard did not exist. The original ETH Registrar formed the pre-cursor to the ERC721 standard. As we witnessed the ERC721 being standardized, support for it was added to the ETH Registrar. Today, users can interact with the ETH Registrar to transfer their name just like with any other ERC721 token. ### Registering a Name Registering a name is a trustless process that takes place onchain (more on this below). Some open source frontends for registering names are the [ENS Manager App](https://app.ens.domains/), [ENS Fairy](https://ensfairy.xyz/), Rainbow Wallet. The process of registering a `.eth` name uses a commit-reveal process. <Card className="flex items-center justify-center gap-8"> <div className="flex flex-col items-center text-center"> <FiHash className="text-2xl" /> <span>Commit</span> </div> <div className="flex flex-col items-center text-center"> <FiClock className="text-2xl" /> <span>Wait</span> </div> <div className="flex flex-col items-center text-center"> <FiBookOpen className="text-2xl" /> <span>Reveal</span> </div> </Card> #### Commit-Reveal The ETHRegistrarController, the highest level contract that users register names through, implements a commit reveal scheme to prevent frontrunning registrations. We first call the `commit` function with an opaque bit of data (the `commitmenthash`), wait 60 seconds, and then call the `register` function. The `commit` function takes a commitment hash, which can be generated using the `makeCommitment` function. The commitment hash is opaque and revealed during the `register` function. The commit-reveal process is to prevent a malicious actor from seeing your `register` transaction in the public mempool and frontrunning it. ```solidity ETHRegistrarController.makeCommitment( name string, owner address, duration uint256, secret bytes32, resolver address, data bytes[], reverseRecord bool, ownerControlledFuses uint16 ) // For example makeCommitment( "myname", // "myname.eth" but only the label 0x1234..., // The address you want to own the name 31536000, // 1 year (in seconds) 0x1234..., // A randomly generated 32 byte secret you create 0x1234..., // The address of the resolver you want to use [0x8b95dd71...], // Encoded function calls you want to pass to the resolver, like `setAddr()` false, // Whether or not to set the new name as your primary name 0 // The NameWrapper fuses you want to set ); ``` Once you have calculated the commitment hash, submit the `commit` transaction. ```solidity ETHRegistrarController.commit(commitment bytes32) ``` After having committed, it is required to wait at least the `MIN_COMMITMENT_AGE` (60 seconds) before making the subsequent `register` transaction. #### Registering Once you have made the onchain commitment and waited 60 seconds, you can register your name. Registration takes in the same parameters as the `makeCommitment` function above. Before initiating registration, ensure that: * `available(label)` == `true`, where `label` is "name" in "name.eth" * `duration` >= `MIN_REGISTRATION_DURATION` * `commitments[commitment]` is between 1 min and 24 hrs old * `msg.value` >= `rentPrice(name, duration)` + `5-10% (slippage)` Because the rent price is paid in ETH but denominated in USD, callers are recommended to send slightly more than the value returned by `rentPrice` to avoid issues with fast price changes. A premium of 3-5% will likely be sufficient. Any excess funds sent during registration are automatically returned to the caller. ```solidity ETHRegistrarController.register( name string, owner address, duration uint256, secret bytes32, resolver address, data bytes[], reverseRecord bool, ownerControlledFuses uint16 ) // For example register( "myname", // "myname.eth" but only the label 0x1234..., // The address you want to own the name 31536000, // 1 year (in seconds) 0x1234..., // The same secret you used in the `commit` transaction 0x1234..., // The address of the resolver you want to use [0x8b95dd71...], // Encoded function calls you want to pass to the resolver, like `setAddr()` false, // Whether or not to set the new name as your primary name 0 // The NameWrapper fuses you want to set ); ``` ### Renewing a Name ```solidity ETHRegistrarController.renew() ``` Any user can renew a domain, not just the owner. This means that if you want to ensure a name doesn't expire you can renew it for someone. By allowing renewal for any arbitrary amount of time users can ensure their name will not expire. As per the separation between registry and controller, even with upgraded controller your name will still be yours. ### Other features ```solidity ETHRegistrarController.MIN_COMMITMENT_AGE uint ETHRegistrarController.MAX_COMMITMENT_AGE uint ETHRegistrarController.MIN_REGISTRATION_DURATION uint // Get Commitment Timestamp ETHRegistrarController.commitments mapping(bytes32=>uint) // Get Rent Price ETHRegistrarController.rentPrice(string name, uint duration) view returns (uint) // Check Name Validity ETHRegistrarController.valid(string name) view returns (bool) // Check Name Availability // Returns true if the name is both valid and available for registration by this controller. ETHRegistrarController.available(string name) view returns (bool) // Calculate Commitment Hash ETHRegistrarController.makeCommitment(string name, address owner, uint256 duration, bytes32 secret, address resolver, bytes[] data, bool reverseRecord, uint16 ownerControlledFuses) view returns (bytes32) // Get Name Expiry (unix timestamp at which registration expires) BaseRegistrar.nameExpires(uint256 label) view returns (uint) // Check Name Availability (less specific, use ETHRegistrarController.available instead) BaseRegistrar.available(uint256 label) view returns (bool) // Get Transfer Period End (unix timestamp at which transfer period (from legacy registrar) ends) BaseRegistrar.transferPeriodEnds uint // Get Controller Status BaseRegistrar.controllers mapping(address=>bool) // Check Token Approval BaseRegistrar.getApproved(uint256 tokenId) view returns (address operator) // Check All Tokens Approval BaseRegistrar.isApprovedForAll(address owner, address operator) view returns (bool) // Get Token Owner BaseRegistrar.ownerOf(uint256 tokenId) view returns (address) // Get Token URI BaseRegistrar.tokenURI(uint256 tokenId) view returns (string) ``` Writable ```solidity // Transfer a Name BaseRegistrar.transferFrom(address from, address to, uint256 tokenId) BaseRegistrar.safeTransferFrom(address from, address to, uint256 tokenId) BaseRegistrar.safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) // Approve Operator BaseRegistrar.approve(address to, uint256 tokenId) // Set Approval For All BaseRegistrar.setApprovalForAll(address operator, bool approved) // Reclaim ENS Record BaseRegistrar.reclaim(uint256 label) ``` Events ```solidity // BaseRegistrar event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event NameMigrated(uint256 indexed hash, address indexed owner, uint expires); event NameRegistered(uint256 indexed hash, address indexed owner, uint expires); event NameRenewed(uint256 indexed hash, uint expires); // Controller event NameRegistered(string name, bytes32 indexed label, address indexed owner, uint cost, uint expires); event NameRenewed(string name, bytes32 indexed label, uint cost, uint expires); ``` ## Reverse Registrars :::info Reverse resolution is part of the [primary name](/web/reverse) feature. If you're just trying to fetch a name for an address, you should start there. ::: Reverse resolution is the process of mapping an EVM address (eg, `0x1234...5678`) to an ENS name on a number of different chains. This is accomplished by using special namespaces in the ENS registry: | Reverse Namespace | Name in the ENS registry | | ------------------ | ------------------------ | | Default (Ethereum) | reverse | | Ethereum | addr.reverse | | Arbitrum | 8000a4b1.reverse | | Base | 80002105.reverse | | Linea | 8000e708.reverse | | Optimism | 8000000a.reverse | | Scroll | 80082750.reverse | L2 namespaces are derived via `[coinTypeAsHex].reverse` as specified in [ENSIP-19](/ensip/19/), and users' reverse records can be resolved via `[address].[reverseNamespace]`. For example, the account `0xb8c2C29ee19D8307cb7255e1Cd9CbDE883A267d5` can claim `b8c2c29ee19d8307cb7255e1cd9cbde883a267d5.addr.reverse` in the ENS registry. After doing so, it can configure a resolver and expose metadata, such as a canonical ENS name for this address. The reverse registrar provides functions to `claim` a reverse record, as well as a convenience function (`setName`) to configure the record as it's most commonly used, as a way of specifying a canonical name for an address. ### Supported Chains Reverse Registrars are deployed on Ethereum Mainnet (L1) and popular L2s (Base, OP Mainnet, Arbitrum One, Scroll, and Linea). This enables users to set a chain-specific reverse record while also supporting a default reverse record on L1 that acts as a fallback when a chain-specific record is not set. In practice, it's strongly recommended to **not** hardcode the reverse registrar addresses because they can change in the future and unexpectedly break your application. Instead, resolve them according to [ENSIP-19](/ensip/19). For convenience, the latest deployments of the reverse registrars are listed below. {/* TODO: Add an example of how to do this */} #### Mainnet Deployments | Chain | Address | | ------------------ | -------------------------------------------------------------------------------------------------------------------------------- | | Default (Ethereum) | [0x283F227c4Bd38ecE252C4Ae7ECE650B0e913f1f9](https://etherscan.io/address/0x283F227c4Bd38ecE252C4Ae7ECE650B0e913f1f9) | | Ethereum | [0xa58E81fe9b61B5c3fE2AFD33CF304c454AbFc7Cb](https://etherscan.io/address/0xa58E81fe9b61B5c3fE2AFD33CF304c454AbFc7Cb) | | Arbitrum One | [0x0000000000D8e504002cC26E3Ec46D81971C1664](https://arbiscan.io/address/0x0000000000D8e504002cC26E3Ec46D81971C1664) | | Base | [0x0000000000D8e504002cC26E3Ec46D81971C1664](https://basescan.org/address/0x0000000000D8e504002cC26E3Ec46D81971C1664) | | Linea | [0x0000000000D8e504002cC26E3Ec46D81971C1664](https://lineascan.build/address/0x0000000000D8e504002cC26E3Ec46D81971C1664) | | Optimism | [0x0000000000D8e504002cC26E3Ec46D81971C1664](https://optimistic.etherscan.io/address/0x0000000000D8e504002cC26E3Ec46D81971C1664) | | Scroll | [0x0000000000D8e504002cC26E3Ec46D81971C1664](https://scrollscan.com/address/0x0000000000D8e504002cC26E3Ec46D81971C1664) | #### Testnet Deployments | L2 Testnet Chain | Address | | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | | Default (Ethereum) | [0x4F382928805ba0e23B30cFB75fC9E848e82DFD47](https://sepolia.etherscan.io/address/0x4F382928805ba0e23B30cFB75fC9E848e82DFD47) | | Ethereum | [0xA0a1AbcDAe1a2a4A2EF8e9113Ff0e02DD81DC0C6](https://sepolia.etherscan.io/address/0xA0a1AbcDAe1a2a4A2EF8e9113Ff0e02DD81DC0C6) | | Arbitrum Sepolia | [0x00000BeEF055f7934784D6d81b6BC86665630dbA](https://sepolia.arbiscan.io/address/0x00000BeEF055f7934784D6d81b6BC86665630dbA) | | Base Sepolia | [0x00000BeEF055f7934784D6d81b6BC86665630dbA](https://sepolia.basescan.org/address/0x00000BeEF055f7934784D6d81b6BC86665630dbA) | | Linea Sepolia | [0x00000BeEF055f7934784D6d81b6BC86665630dbA](https://sepolia.lineascan.build/address/0x00000BeEF055f7934784D6d81b6BC86665630dbA) | | Optimism | [0x00000BeEF055f7934784D6d81b6BC86665630dbA](https://sepolia-optimism.etherscan.io/address/address/0x00000BeEF055f7934784D6d81b6BC86665630dbA) | | Scroll Sepolia | [0x00000BeEF055f7934784D6d81b6BC86665630dbA](https://sepolia.scrollscan.com/address/0x00000BeEF055f7934784D6d81b6BC86665630dbA) | ### Setting Records The updated Reverse Registrar interface exposes methods to support that make it easier to set a reverse record for an EOA or smart contract: ```solidity /// @notice Sets the `name()` record for the reverse ENS record associated with the calling account. /// @param name The name to set /// @return The ENS node hash of the reverse record function setName(string memory name) external returns (bytes32); /// @notice Sets the `name()` record for the reverse ENS record associated with the addr provided account. /// Can be used if the addr is a contract that is owned by an SCA. /// @param addr The address to set the name for /// @param name The name to set /// @return The ENS node hash of the reverse record function setNameForAddr( address addr, string memory name ) external returns (bytes32); /// @notice Sets the `name()` record for the reverse ENS record associated with the contract provided that is owned with `Ownable`. /// @param contractAddr The address of the contract to set the name for (implementing Ownable) /// @param owner The owner of the contract (via Ownable) /// @param name The name to set /// @param coinTypes The coin types to set. Must be inclusive of the coin type for the contract /// @param signatureExpiry The expiry of the signature /// @param signature The signature of an address that will return true on isValidSignature for the owner /// @return The ENS node hash of the reverse record function setNameForOwnableWithSignature( address contractAddr, address owner, string calldata name, uint256[] memory coinTypes, uint256 signatureExpiry, bytes calldata signature ) external returns (bytes32); /// @notice Sets the `name()` record for the reverse ENS record associated with the addr provided account using a signature. /// @param addr The address to set the name for /// @param name The name of the reverse record /// @param coinTypes The coin types to set. Must be inclusive of the coin type for the contract /// @param signatureExpiry Date when the signature expir
프로젝트로 돌아가기