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
To fetch the record for a specific name, you can use one of the following methods:
// https://wagmi.sh/react/api/hooks/useEnsText
import { normalize } from 'viem/ens'
import { useEnsText } from 'wagmi'
export const MyProfile: FC<{ name: string }> = ({ name }) => {
const { data } = useEnsText({
name: normalize('nick.eth'),
key: 'com.twitter',
})
return (
<div>
<span>Twitter: {data}</span>
</div>
)
}
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.