Set Domain
Set Domain
This POST route is used to set domain records. It should only be used for domains already enabled in namestone. To enable a new domain use enable-domain.
Parameters
  • domain (string): The domain ("testbrand.eth").
  • address (string): The ethereum address the name points to.
  • contenthash (string)(Optional): The link for an ipfs or ipns website.
  • text_records (object)(Optional): An object containing key-value pairs representing the text records to be set.
Curl Example
curl -X POST \ -H 'Content-Type: application/json' \ -H 'Authorization: YOUR_API_KEY' \ -d '{ "domain":"testbrand.eth", "address":"0xE997d9b785Dd99832d21b3Ce5A34fCacC6D53C57", "text_records": { "com.twitter":"namestonehq", "com.github":"aslobodnik", "com.discord":"superslobo", "url":"https://www.namestone.xyz", "location":"📍 nyc", "description":"APIs are cool", "avatar":"https://raw.githubusercontent.com/aslobodnik/profile/main/pic.jpeg" } }' \ https://namestone.xyz/api/public_v1/set-domain
SDK Example
import NameStone, { AuthenticationError, NetworkError, TextRecords } from 'namestone-sdk';

// Initialize the NameStone instance
const ns = new NameStone(<YOUR_API_KEY_HERE>);

// Define the domain parameters
const domain = "testbrand.eth";
const address = "0xE997d9b785Dd99832d21b3Ce5A34fCacC6D53C57";

// Define the text records
const textRecords: TextRecords = {
  "com.twitter": "namestonehq",
  "com.github": "aslobodnik",
  "com.discord": "superslobo",
  "url": "https://www.namestone.xyz",
  "location": "📍 nyc",
  "description": "APIs are cool",
  "avatar": "https://raw.githubusercontent.com/aslobodnik/profile/main/pic.jpeg"
};

// Use an immediately invoked async function to allow top-level await
(async () => {
  try {
    const response = await ns.setDomain({domain:domain, address:address, text_records:textRecords});

    console.log("Domain set successfully:", response);
  } catch (error) {
    if (error instanceof AuthenticationError) {
      console.error("Authentication failed:", error.message);
    } else if (error instanceof NetworkError) {
      console.error("Network error:", error.message);
    } else {
      console.error("An unexpected error occurred:", error);
    }
  }
})();