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.
These methods allow you to manage text records for a given ENS subname. You can fetch, add, update, or delete individual records.
1. addTextRecord
Add or update a text record.
client.addTextRecord({
subname: "ns.myensname.eth",
key: "description",
value: "HODL ENS!",
});
Parameters:
subname - Full ENS subname
key - Text record key (e.g., “description”)
value - Value to associate with the key
2. deleteTextRecord
Delete a text record.
client.deleteTextRecord({ subname: "ns.myensname.eth", key: "description" });
3. getTextRecords
Get all text records for a subname.
const records = await client.getTextRecords("ns.myensname.eth");
// Returns: Record<string, string>
4. getTextRecord
Get a specific text record by key.
const response = await client.getTextRecord("ns.myensname.eth", "description");
const description = response.record;
Return Type:
interface GetRecordResponse {
record: string;
}