Smart Contracts
X1NS is built on Solana’s SPL Name Service with custom extensions for the X1 blockchain.
Contract Addresses
X1 Mainnet
| Contract | Address |
|---|---|
| Registrar Program | X1NS1M4Lh9zwpYe7Mi2RKyy7QWq7dRtqyr7KxsLyUn5 |
| SPL Name Service | nameQyUhZQQgnirGbbJRR9ECWSdq1W7mMaNUZZTBvtq |
| Treasury | 2sgQ7LzA7urZ4joMy4uU3Rcus82ZoLbHa54UvChJc9j3 |
Root Domain Authorities (Mainnet)
| TLD | Root Domain Address |
|---|---|
| .x1 | 4NG35LXbtyamuoyjarMf5f78esyWxWhSDHxqbAU5yZTk |
| .xnt | 6sHoWK6ht73Pb4y6yA7Sw8iP7DxS45gGp1fH3zWYn56V |
| .xen | 3SUwpSz33AsyJwf6B48cKZuDTswuUEdUhcXszZrFWPqo |
X1 Testnet
| Contract | Address |
|---|---|
| Registrar Program | EA7qtWCf2qCJ4ERPiYtqqTKMF4qUR6kvcYmq9WG7A8GT |
| SPL Name Service | HoxHN4YSynWfdS3fuB2RtBQsMjTKX3Vn3vdyafq4iXZG |
Contract Architecture
Components
-
Registrar Program - Custom X1NS logic
- Domain registration
- Pricing configuration
- Primary domain management
- Profile records
- NFT tokenization
- Marketplace operations
-
SPL Name Service - Core naming infrastructure
- Domain account creation
- Name resolution
- Ownership management
- Subdomain support
-
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 domaincentral_state- Central state PDAtreasury- Treasury account (writable)spl_name_service- SPL Name Service programsystem_program- System programrent- 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 accountprimary_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 ownerdomain- 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 programtoken_program- SPL Token programsystem_program- System programrent- 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 ownerparent_domain- Parent domain accountsubdomain- Subdomain account (writable, to be created)subdomain_reverse- Subdomain reverse lookup (writable, to be created)spl_name_service- SPL Name Service programsystem_program- System programrent- Rent sysvar
Parameters:
pub struct CreateSubdomainParams {
pub name: String, // Subdomain name (e.g., "wallet")
}Program Derived Addresses (PDAs)
Central State
seeds = [b"central_state"],
bumpPrimary Domain Record
seeds = [b"primary_domain", owner.key().as_ref()],
bumpProfile Record
seeds = [b"profile", domain.key().as_ref()],
bumpReverse 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.xyzTestnet
https://rpc.testnet.x1.xyzSource Code
The X1NS smart contracts are open source:
- GitHub: github.com/x1labs/x1ns
- Programs:
/packages/x1ns-programs/ - Language: Rust (Anchor framework)
Next Steps
- SDK Reference - Use the TypeScript SDK
- API Reference - REST API docs
- Integration Examples - Full examples