ENS Logo

Text Records

With every name come a set of records. These records are key value pairs that can be used to store information about the profile. Think of this as a user's digital backpack. Utalized for storage of preferences, public details, and more.

nick.eth➡️
displayNick.eth
descriptionLead developer of ENS
avataripfs://Qm...
com.twitternicksdjohnson

Text records allow us to attach and read any key value pair from an ENS name. 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:

Get records by name
import { useEnsText } from "wagmi";
import { normalize } from "viem/ens";

export const MyProfile: FC<{ name: string }> = ({ name }) => {
    const { data } = useEnsText({
        name: normalize("luc.eth"),
        key: "com.twitter",
    });

    return (
        <div>
            <span>Twitter: </span><span>{data}</span>
        </div>
    );
};
const provider = new ethers.providers.JsonRpcProvider();

const resolver = await provider.getResolver("luc.eth");
const twitter = await resolver.getText("com.twitter");
import { normalize } from "viem/ens";
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";

const publicClient = createPublicClient({
    chain: mainnet,
    transport: http(),
});

const ensText = await publicClient.getEnsText({
    name: normalize("luc.eth"),
    key: "com.twitter",
});
from ens.auto import ns

# set text
ns.set_text('alice.eth', 'url', 'https://example.com')

# get text
url = ns.get_text('alice.eth', 'url')
assert url == 'https://example.com'
// TODO: Not Implemented
package main

import (
	"fmt"

	"github.com/ethereum/go-ethereum/ethclient"
	ens "github.com/wealdtech/go-ens/v3"
)

func main() {
	client, _ := ethclient.Dial("https://rpc.ankr.com/eth")

	domain, _ := ens.Normalize("luc.eth")
	resolver, _ := ens.NewResolver(client, domain)
	twitter, _ := resolver.Text("com.twitter")

	fmt.Println("Twitter: ", twitter)
}

Types of Records

Here are some of the most commonly used records:

NameUsageReferenceExample
displayPreferred CapitalizationENSIP-5Luc.eth
avatarAvatar or Logo (see Avatars)ENSIP-5ipfs://dQw4w9WgXcQ
descriptionDescription of the nameENSIP-5DevRel @ ENS Labs
keywordsA list of comma-separated keywordsENSIP-5person, ens
emailEmail AddressENSIP-5luc@ens.domains
mailA physical mailing addressENSIP-5V3X HQ
noticeA notice regarding this nameENSIP-5This is a notice
locationA generic location (e.g. "Toronto, Canada")ENSIP-5Breda, NL
phoneA phone number as an E.164 stringENSIP-5+1 234 567 890
urla website URLENSIP-5https://ens.domains

Other Records

Currently there are a few records that have been standardised. However you are welcome 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.

Header/Banner Record

An example of a "yet to be standardised" record is the "header" record. From initial community usage this header record, similar to the avatar record, accepts any IPFS, Arweave, EIP155, or regular URL to an image resource. The image is then displayed as a banner on the profile page and tends to be in a 1:3 aspect ratio.

luc.eth
pedrouid.eth
coltron.eth

Setting Records

When records are loaded they are loaded from the resolver responsible for the name. As resolvers are user controlled, we cannot guarantee a write function is available. This makes it a more in-depth process to update a users records.

Interacting with a ResolverTo learn more about interacting with a resolver.Advanced
Contributors
Last Modified
last month