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.
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.
To fetch the record for a specific name, you can use one of the following methods:
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",
});
// 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)
}
Here are some of the most commonly used records:
Name | Usage | Reference | Example |
---|---|---|---|
display | Preferred Capitalization | ENSIP-5 | Luc.eth |
avatar | Avatar or Logo (see Avatars) | ENSIP-5 | ipfs://dQw4w9WgXcQ |
description | Description of the name | ENSIP-5 | DevRel @ ENS Labs |
keywords | A list of comma-separated keywords | ENSIP-5 | person, ens |
Email Address | ENSIP-5 | luc@ens.domains | |
A physical mailing address | ENSIP-5 | V3X HQ | |
notice | A notice regarding this name | ENSIP-5 | This is a notice |
location | A generic location (e.g. "Toronto, Canada") | ENSIP-5 | Breda, NL |
phone | A phone number as an E.164 string | ENSIP-5 | +1 234 567 890 |
url | a website URL | ENSIP-5 | https://ens.domains |
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.
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.
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.