Text Records
Text records are key-value pairs that can be used to store any arbitrary data associated with a name. Think of this as a user's digital backpack utilized for the storage of preferences, public details, and more.
| Key | Value |
|---|
The most popular records have been standardised. One example of a standardised record is the avatar record which is used to store a user's profile picture.
Getting Records
Read records through the Universal Resolver using an ENSv2-ready library: viem 2.35.0 or later or ethers 6.17.0 or later. The Wagmi example was tested with Wagmi 2.19.5 and viem 2.57.10. Use that pair with the provider setup.
Replace <MAINNET_RPC_URL> with your Ethereum Mainnet RPC endpoint in each example.
import { normalize } from 'viem/ens'
import { useEnsText } from 'wagmi'
export function Profile({ name }: { name: string }) {
const { data, isPending, error } = useEnsText({
name: normalize(name),
key: 'com.twitter',
chainId: 1,
})
if (isPending) return <span>Loading…</span>
if (error) return <span>Lookup failed</span>
return <span>Twitter: {data ?? 'No record set'}</span>
}The examples read existing records. A missing name, resolver, or record needs an appropriate empty or error state in your application.
Types of Records
ENSIP-5 and ENSIP-18 specify two sets of records that are considered standardized. Below are some of the most commonly ones:
| Name | Usage | Reference | Example |
|---|---|---|---|
| avatar | Avatar | ENSIP-5 | eip155:1/erc1155:0x495f... |
| description | Bio or description of the profile | ENSIP-5 | Lead developer of ENS |
| com.twitter | Twitter/X handle | ENSIP-5 | nicksdjohnson |
| com.github | GitHub handle | ENSIP-5 | arachnid |
| url | Website URL | ENSIP-5 | https://ens.domains |
| header | Image URL to be used as a header/banner | ENSIP-18 | ipfs://QmNtHN7WE... |
Custom Records
While standardized records are expected to have the best ecosystem support, it's possible to store any key-value pair you desire. We generally recommend to stick to a pattern, or prefix things with your app or protocol (eg. com.discord, or org.reddit), as such to avoid collisions.
Setting Records
Text records are controlled by the resolver associated with a given name. Read more about interacting with a resolver.