Enable Domain
Enable Domain
To enable a domain for NameStone programmatically, call this POST route. It returns an API key.
Endpoint Prerequisites:
  • You must first sign a message from the Get SIWE Message endpoint.
  • Your domain must use the NameStone resolver: 0xA87361C4E58B619c390f469B9E6F27d759715125. Learn more about updating the resolver.
Prefer a UI? Fill out our form instead.
Parameters
ParameterTypeRequiredDescription
company_namestringYesThe name of your company.
emailstringYesYour email which will receive the API key.
addressstringYesThe Ethereum address that owns the domain.
domainstringYesThe domain (e.g. "testbrand.eth") you wish to enable.
signaturestringYesThe message from get-siwe-message, signed with your Ethereum address.
api_keystringNoTo use an existing NameStone API key that your wallet has access to, add it here.
cycle_key"1" or "0"NoIf 1 and the API key already exists, the key will be cycled.
Curl Example
curl -X POST \ -H 'Content-Type: application/json' \ -d '{ "company_name": "your_company_name", "email": "your_email@company.com", "domain":"testbrand.eth", "address":"0xE997d9b785Dd99832d21b3Ce5A34fCacC6D53C57", "signature": "signed_siwe_message" }' \ https://namestone.com/api/public_v1/enable-domain
SDK Example with getSiweMessage
import NameStone, {
  AuthenticationError,
  NetworkError,
} from "@namestone/namestone-sdk";
import { createWalletClient, custom } from "viem"; // if using viem for signing

// Initialize the NameStone instance (no API key needed for initial setup)
const ns = new NameStone();

// Define the parameters
const address = "0xE997d9b785Dd99832d21b3Ce5A34fCacC6D53C57";
const domain = "testbrand.eth";
const email = "your_email@company.com";
const company_name = "Your Company Name";

// Use an immediately invoked async function to allow top-level await
(async () => {
  try {
    // Step 1: Get the SIWE message
    const siweMessage = await ns.getSiweMessage({
      address: address,
    });

    console.log("SIWE message received:", siweMessage);

    // Step 2: Sign the message (example using viem)
    const walletClient = createWalletClient({
      transport: custom(window.ethereum),
    });

    const signature = await walletClient.signMessage({
      message: siweMessage,
    });

    console.log("Message signed:", signature);

    // Step 3: Enable domain with the signed message
    const response = await ns.enableDomain({
      company_name: company_name,
      email: email,
      domain: domain,
      address: address,
      signature: signature,
      // Optional parameters:
      // api_key: "existing_api_key",  // if you want to use an existing key
      // cycle_key: "1"                // if you want to cycle an existing key
    });

    console.log("Domain enabled successfully! New API key:", response.api_key);

    // Step 4: You can now initialize a new NameStone instance with the API key
    const nsWithAuth = new NameStone(response.api_key);

    // Now you can use other endpoints that require authentication...
  } 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);
    }
  }
})();