Set Name
Set Name
This POST route creates a name (subdomain) for a given address and domain. If the name already exists, it will be overwritten. If it doesn’t, this route will create it.
Parameters
ParameterTypeRequiredDescription
namestringYesThe name being set, i.e., the "example" in example.testbrand.eth.
domainstringYesThe domain (e.g. "testbrand.eth").
addressstringNoThe Ethereum address the name points to.
contenthashstringNoThe link for an IPFS or IPNS website.
text_recordsobjectNoAn object containing key-value pairs of the text records to be set.
coin_typesobjectNoAn object containing key-value pairs of L2 chains and their resolved address.
Multichain Address Resolution
Namestone supports address resolution on any L2 Chains Supported by ENS.
To add an address to an L2 chain use its coin_type. (See coin_type column in the above link) .
Or convert chain_id to coin_type using the following typescript template.
Curl Example with coin_types
curl -X POST \ -H 'Content-Type: application/json' \ -H 'Authorization: YOUR_API_KEY' \ -d '{ "domain": "namestone.xyz", "name": "multichain", "address": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF", "coin_types": { "2147483785": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF", "2147492101": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF", "2147525809": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF", "2147483658": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF" }, "text_records": { "com.twitter": "namestonehq", "com.github": "resolverworks", "url": "https://www.namestone.xyz", "description": "Multichain Example", "avatar": "https://imagedelivery.net/UJ5oN2ajUBrk2SVxlns2Aw/e52988ee-9840-48a2-d8d9-8a92594ab200/public" } }' \ https://namestone.com/api/public_v1/set-name
SDK Example with coin_types
import NameStone, { AuthenticationError, NetworkError, TextRecords, CoinTypes } from '@namestone/namestone-sdk';

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

// Define the name parameters
const domain = "namestone.xyz;
const name = "multichain";
const address = "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF";

// Define the coin types
const coinTypes: CoinTypes = {
  "2147483785": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF",
  "2147492101": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF",
  "2147525809": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF",
  "2147483658": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF"
};

// Define the text records
const textRecords: TextRecords = {
  "com.twitter": "namestonehq",
  "com.github": "resolverworks",
  "url": "https://www.namestone.xyz",
  "description": "Multichain Example",
  "avatar": "https://imagedelivery.net/UJ5oN2ajUBrk2SVxlns2Aw/e52988ee-9840-48a2-d8d9-8a92594ab200/public"
};

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

    console.log("Name 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);
    }
  }
})();
Live Example: See multichain.namestone.xyz on the ENS app.
Image