Skip to content

Resolve

You can resolve .night domains directly from a terminal without writing a full application.

  • Bun (or Node.js ≥ 20 with tsx)
  • @midnames/sdk installed in your project
Terminal window
bun add @midnames/sdk
# or: npm install @midnames/sdk
  1. Create a script file

    Save this as resolve.ts:

    import { resolveDomain, createDefaultProvider } from "@midnames/sdk";
    const domain = process.argv[2];
    if (!domain) {
    console.error("Usage: bun run resolve.ts <domain.night>");
    process.exit(1);
    }
    // Passing networkId: "preprod" sets both the indexer endpoint
    // and the preprod contract address automatically.
    const provider = createDefaultProvider({ networkId: "preprod" });
    const result = await resolveDomain(domain, { provider });
    if (result.success) {
    console.log("Type: ", result.data.type);
    console.log("Address:", result.data.address);
    } else {
    console.error("Error:", result.error.message);
    process.exit(1);
    }
  2. Run it

    Terminal window
    bun run resolve.ts mid.night

    You should see output similar to:

    Type: unshielded
    Address: mn1qqgqqf...