Developer GuideSmart Contracts

Smart Contracts

X1NS is built on Solana’s SPL Name Service with custom extensions for the X1 blockchain.

Contract Addresses

X1 Mainnet

ContractAddress
Registrar ProgramX1NS1M4Lh9zwpYe7Mi2RKyy7QWq7dRtqyr7KxsLyUn5
SPL Name ServicenameQyUhZQQgnirGbbJRR9ECWSdq1W7mMaNUZZTBvtq
Treasury2sgQ7LzA7urZ4joMy4uU3Rcus82ZoLbHa54UvChJc9j3

Root Domain Authorities (Mainnet)

TLDRoot Domain Address
.x14NG35LXbtyamuoyjarMf5f78esyWxWhSDHxqbAU5yZTk
.xnt6sHoWK6ht73Pb4y6yA7Sw8iP7DxS45gGp1fH3zWYn56V
.xen3SUwpSz33AsyJwf6B48cKZuDTswuUEdUhcXszZrFWPqo

X1 Testnet

ContractAddress
Registrar ProgramEA7qtWCf2qCJ4ERPiYtqqTKMF4qUR6kvcYmq9WG7A8GT
SPL Name ServiceHoxHN4YSynWfdS3fuB2RtBQsMjTKX3Vn3vdyafq4iXZG

Contract Architecture

Components

  1. Registrar Program - Custom X1NS logic

    • Domain registration
    • Pricing configuration
    • Primary domain management
    • Profile records
    • NFT tokenization
    • Marketplace operations
  2. SPL Name Service - Core naming infrastructure

    • Domain account creation
    • Name resolution
    • Ownership management
    • Subdomain support
  3. Central State - Global configuration PDA

    • Pricing rules
    • TLD root domains
    • Treasury address
    • Feature flags

Instructions

Register Domain

Create a new domain registration.

Accounts:

  • payer - Fee payer (signer, writable)
  • domain_owner - Domain owner (writable)
  • domain - Domain account (writable, to be created)
  • reverse_lookup - Reverse lookup account (writable, to be created)
  • root_domain - TLD root domain
  • central_state - Central state PDA
  • treasury - Treasury account (writable)
  • spl_name_service - SPL Name Service program
  • system_program - System program
  • rent - Rent sysvar

Parameters:

pub struct RegisterDomainParams {
    pub name: String,  // Domain name (without TLD)
}

Example:

import { Transaction } from '@solana/web3.js';
 
const instruction = await createRegisterDomainInstruction(
  connection,
  wallet.publicKey,
  'alice'
);
 
const tx = new Transaction().add(instruction);
const sig = await sendAndConfirmTransaction(connection, tx, [wallet]);

Set Primary Domain

Set a domain as the user’s primary Web3 identity.

Accounts:

  • owner - Domain owner (signer)
  • domain - Domain account
  • primary_record - Primary domain PDA (writable, to be created)
  • system_program - System program

Example:

const instruction = await createSetPrimaryDomainInstruction(
  wallet.publicKey,
  domainAccount
);

Transfer Domain

Transfer domain ownership to another address.

Accounts:

  • current_owner - Current owner (signer)
  • new_owner - New owner
  • domain - Domain account (writable)
  • spl_name_service - SPL Name Service program

Parameters:

pub struct TransferDomainParams {
    pub new_owner: Pubkey,
}

Tokenize Domain

Convert a domain to an NFT.

Accounts:

  • owner - Domain owner (signer, writable)
  • domain - Domain account (writable)
  • nft_mint - NFT mint account (writable, to be created)
  • nft_metadata - NFT metadata account (writable, to be created)
  • token_account - Owner’s token account (writable, to be created)
  • metadata_program - Metaplex Metadata program
  • token_program - SPL Token program
  • system_program - System program
  • rent - Rent sysvar

Update Profile

Update domain profile records (social links, addresses).

Accounts:

  • owner - Domain owner (signer)
  • domain - Domain account (writable)
  • profile_record - Profile PDA (writable, to be created if needed)
  • system_program - System program

Parameters:

pub struct UpdateProfileParams {
    pub twitter: String,
    pub discord: String,
    pub website: String,
    pub x1_address: Option<Pubkey>,
    pub sol_address: Option<Pubkey>,
    pub eth_address: Option<String>,
    pub btc_address: Option<String>,
}

Create Subdomain

Create a subdomain under a parent domain.

Accounts:

  • payer - Fee payer (signer, writable)
  • parent_owner - Parent domain owner (signer)
  • subdomain_owner - Subdomain owner
  • parent_domain - Parent domain account
  • subdomain - Subdomain account (writable, to be created)
  • subdomain_reverse - Subdomain reverse lookup (writable, to be created)
  • spl_name_service - SPL Name Service program
  • system_program - System program
  • rent - Rent sysvar

Parameters:

pub struct CreateSubdomainParams {
    pub name: String,  // Subdomain name (e.g., "wallet")
}

Program Derived Addresses (PDAs)

Central State

seeds = [b"central_state"],
bump

Primary Domain Record

seeds = [b"primary_domain", owner.key().as_ref()],
bump

Profile Record

seeds = [b"profile", domain.key().as_ref()],
bump

Reverse Lookup

Calculated via SPL Name Service:

getReverseLookupKey(domainAccount, centralState, splNameServiceProgram)

Events / Logs

The smart contracts emit JSON-formatted logs for indexing:

Domain Registered

{
  "type": "domain_registered",
  "name": "alice",
  "domain": "X1abc123...",
  "owner": "X1def456...",
  "price": 1000000000,
  "tld": "X1ghi789...",
  "length": 5
}

Domain Tokenized

{
  "event": "tokenization",
  "domain": "alice",
  "domain_address": "X1abc123...",
  "nft_mint": "X1nft456...",
  "owner": "X1def789...",
  "collection": "x1ns_collection"
}

Primary Domain Set

{
  "event": "primary_domain_set",
  "domain": "X1abc123...",
  "owner": "X1def456...",
  "is_nft": false
}

Profile Updated

{
  "event": "profile_updated",
  "domain": "X1abc123...",
  "owner": "X1def456...",
  "avatar": "",
  "twitter": "@alice",
  "discord": "alice#1234",
  "github": "",
  "website": "https://alice.com",
  "bio": ""
}

Security

Ownership Verification

All privileged operations verify ownership:

require!(
    domain.owner == owner.key(),
    ErrorCode::Unauthorized
);

Signature Verification

Critical operations require signatures:

require!(
    owner.is_signer,
    ErrorCode::MissingSignature
);

Rent Exemption

All accounts are rent-exempt for permanence:

let rent = Rent::get()?;
require!(
    account_lamports >= rent.minimum_balance(account_size),
    ErrorCode::InsufficientFunds
);

RPC Endpoints

Mainnet

https://rpc.mainnet.x1.xyz

Testnet

https://rpc.testnet.x1.xyz

Source Code

The X1NS smart contracts are open source:


Next Steps