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
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.
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
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.
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...
Last updated