For the complete documentation index, see llms.txt. This page is also available as Markdown.

📚Records

Handle the records of your domain

A domain record has the following fields:

  • class: The class of the record, chosen from a predefined list of possibilities.

  • data: The data associated with the record, which can be a string or a buffer, depending on the record class.

Available record classes

RecordClassEnum exposes the following classes:

Class
Value

Bio

0

Discord

1

Twitter

2

Uri

3

Wallet

4

Avatar

5

Email

6

Price

7

Main

8

The web app offers Bio, Email, Twitter, Discord, Wallet, Price and Uri. Avatar and Main exist on chain but are not exposed there.

Getting a record repository

Records are managed through the repository attached to a domain:

import { RecordClassEnum } from '@metanames/sdk'

const domain = await metaNamesSdk.domainRepository.find('supercool.mpc')
if (!domain) throw new Error('Domain not found')

const recordRepository = domain.getRecordRepository(metaNamesSdk)

Creating, updating and deleting records are write operations, so a signing strategy must be set first — see Getting started.

Creating a domain record

Provide the class and data fields for the new record:

Replace RecordClassEnum.Wallet with the desired record class and 'data' with the appropriate data for the record. To create several records in a single transaction, pass an array to createBatch.

Updating a domain record

Replace RecordClassEnum.Wallet with the class of the record you want to update and 'newData' with the updated data.

Deleting a domain record

delete takes the record class directly, not an object:

Reading a domain record

find takes the record class and reads from the domain data already loaded, returning null when the domain has no record of that class:

Example usage

Here's an example of how you can use these functionalities together:

Replace RecordClassEnum.Uri and the URLs with your actual values.

Last updated