# Subdomains

Subdomains in Solana Name Service (SNS) are similar to `.sol` domains but have a different parent. They can be considered as normal domains but from a different Top-Level Domain (TLD). For instance, `something.example.sol` can be considered the something subdomain of `example.sol` or a domain from the TLD `example.sol`.

### Key Characteristics of Subdomains <a href="#key-characteristics-of-subdomains" id="key-characteristics-of-subdomains"></a>

* **Parent Ownership:** The owner of the parent domain retains the ability to transfer subdomains without the signature from the owner of the subdomains. This is a unique feature of subdomains in SNS.
* **Limited Wallet Support:** Subdomains have limited wallet support. This means that not all wallets may support transactions involving subdomains.
* **Feature Support:** Subdomains support the same features as main domains. This includes the ability to transfer and update data.

### Create a Subdomain

A subdomain created with `createSubdomain` will initially be owned by the parent owner. A subdomain can be created and transfered inside the same transaction.

```typescript
import { createSubdomain } from "@bonfida/spl-name-service";

// The subdomain to create with or without .sol e.g something.bonfida.sol or something.bonfida
const subdomain = "something.bonfida.sol";

// The owner of the parent domain
const owner = new PublicKey("...");

const ix = createSubdomain(connection, subdomain, owner);

// Sign and send the tx...
```

### Transfer a Subdomain

```typescript
import { transferSubdomain } from "@bonfida/spl-name-service";

// Subdomains to transfer
const subdomain = "something.bonfida.sol";

// New owner of the domain
const newOwner = new PublicKey("...");

// Whether the parent name owner is signing the transfer
const isParentSigner = false;

const ix = await transferSubdomain(
  connection,
  subdomain,
  newOwner,
  isParentSigner
);

// sign and send instruction
```

### Delete a Subdomain

While the deletion of a subdomain is a reversible action, it's important to be mindful of potential unintended consequences.

```typescript
import { deleteInstruction, getDomainKeySync, NAME_PROGRAM_ID } from "@bonfida/spl-name-service";

// The subdomain to create with or without .sol e.g something.bonfida.sol or something.bonfida
const subdomain = "something.bonfida.sol";

// The owner of the subdomain
const owner = new PublicKey("...");

const { pubkey: domainKey } = getDomainKeySync(domain);

const ix = deleteInstruction(
  NAME_PROGRAM_ID,
  domainKey,
  owner,
  owner
);

// sign and send the instruction...
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sns.id/dev/sns-sdk/subdomains.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
