📚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

The following classes are available for domain records:

  • Bio

  • Discord

  • Twitter

  • Uri

  • Wallet

  • Avatar

Minting a Domain Record

Minting a domain record involves creating a new record associated with a domain. You need to provide the class and data fields for the new record. Here's how you can use the mint function to achieve this:

const { transactionHash, fetchResult } = await domain.getRecordRepository(metaNamesSdk).create({
  class: RecordClassEnum.Wallet,
  data: 'data'
});
console.log(`Transaction hash: ${transactionHash}`);
const result = await fetchResult;
console.log(`Domain record mint submitted: ${result}`);

Replace 'RecordClassEnum.Wallet' with the desired record class and 'data' with the appropriate data for the record.

Updating a Domain Record

To update an existing domain record, you can use the update function. Here's how you can use the update function:

const { transactionHash, fetchResult } = await domain.getRecordRepository(metaNamesSdk).update({
  class: RecordClassEnum.Wallet,
  data: 'newData'
});
console.log(`Transaction hash: ${transactionHash}`);
const result = await fetchResult;
console.log(`Domain record update submitted: ${result}`);

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

Deleting a Domain Record

Deleting an existing domain record can be achieved using the delete function. Here's how you can use the delete function:

const { transactionHash, fetchResult } = await domain.getRecordRepository(metaNamesSdk).delete({
  class: RecordClassEnum.Wallet
});
console.log(`Transaction hash: ${transactionHash}`);
const result = await fetchResult;
console.log(`Domain record delete submitted: ${result}`);

Replace 'RecordClassEnum.Wallet' with the class of the record you want to delete.

Example Usage

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

// Mint a new domain record
const { transactionHash: mintTransactionHash, fetchResult: mintFetchResult } = await domain.getRecordRepository(metaNamesSdk).mint({
  class: RecordClassEnum.Uri,
  data: 'website'
});
console.log(`Transaction hash: ${mintTransactionHash}`);
const mintResult = await mintFetchResult;
console.log(`Domain record mint submitted: ${mintResult}`);

// Update the existing domain record
const { transactionHash: updateTransactionHash, fetchResult: updateFetchResult } = await domain.getRecordRepository(metaNamesSdk).update({
  class: RecordClassEnum.Uri,
  data: 'new-website'
});
console.log(`Transaction hash: ${updateTransactionHash}`);
const updateResult = await updateFetchResult;
console.log(`Domain record update submitted: ${updateResult}`);

// Delete the existing domain record
const { transactionHash: deleteTransactionHash, fetchResult: deleteFetchResult } = await domain.getRecordRepository(metaNamesSdk).delete({
  class: RecordClassEnum.Uri
});
console.log(`Transaction hash: ${deleteTransactionHash}`);
const deleteResult = await deleteFetchResult;
console.log(`Domain record delete submitted: ${deleteResult}`);

Replace 'RecordClassEnum.Uri', 'website', and 'new-website' with your actual values.

Last updated