Skip to Content
Native FeaturesTOS Name Service (TNS)

TOS Name Service (TNS)

TOS Name Service (TNS) provides human-readable account names similar to ENS on Ethereum. Instead of using cryptographic addresses like tos1qxy2kgdyg..., users can register names like alice@tos.network.

Implementation Status

FeatureStatus
Name RegistrationImplemented
Name ResolutionImplemented
Ephemeral Messages (ECDH encrypted)Implemented
TNS-aware TransfersImplemented
Wallet CommandsImplemented
Unit Tests (63)Passing

Features Overview

TNS (TOS Name Service) ----------------------------------------------- 1. Name Registration alice registers -> alice@tos.network 2. Address Resolution alice@tos.network -> tos1qxy2kgdyg... 3. Ephemeral Messages (like Signal disappearing messages) alice@tos.network -> bob@tos.network Messages auto-delete after N blocks

Design Decisions

FeatureDecision
Formatusername@tos.network (fixed suffix)
Storageblake3 hash (privacy protection)
Registration Fee0.1 TOS
LimitOne name per account
ChangeabilityNot changeable after registration
TransferabilityNot transferable (permanently bound)
Message TTL100-86,400 blocks (~30 min to 3 days)
Max Message Size140 bytes

Name Registration

Naming Rules

RuleDescription
Length3-64 characters
Allowed CharactersLowercase a-z, digits 0-9
Allowed SeparatorsPeriod ., hyphen -, underscore _
Start CharacterMust start with a letter
End CharacterCannot end with a separator
Consecutive SeparatorsNot allowed (e.g., .., --, ._)
Reserved Namesadmin, system, tos, root, null, test, etc.

Valid Examples

  • alice -> alice@tos.network
  • john.doe -> john.doe@tos.network
  • alice-wang -> alice-wang@tos.network
  • user_123 -> user_123@tos.network

Invalid Examples

  • ab - Too short (< 3 characters)
  • 123abc - Starts with digit
  • .alice - Starts with separator
  • alice. - Ends with separator
  • alice..bob - Consecutive separators
  • admin - Reserved name

Registration via CLI

# Register a name tos_wallet register_name name=alice # Registration costs 0.1 TOS

Registration via SDK

const tx = await tos.sendTransaction({ type: 'RegisterName', payload: { name: 'alice' } }); // After confirmation, alice@tos.network is registered

Name Resolution

RPC Query

// Resolve name to address const result = await fetch('/resolve_name', { method: 'POST', body: JSON.stringify({ name: 'bob' }) }).then(r => r.json()); // result.address = 'tos1qxy2kgdyg...'

Wallet Command

# Resolve a name tos_wallet resolve_name name=bob # Output: bob@tos.network -> tos1qxy2kgdyg...

TNS-Aware Transfers

You can send funds directly to TNS names instead of addresses:

# Transfer using TNS name tos_wallet transfer address=bob@tos.network asset=TOS amount=100 # Transfer all balance tos_wallet transfer_all address=alice@tos.network asset=TOS

The wallet automatically resolves @tos.network suffixes to addresses.

Ephemeral Messages

TNS supports ephemeral messages - encrypted messages that automatically disappear after a specified number of blocks. Similar to Signal’s disappearing messages feature.

Message Features

  • End-to-end Encryption: ECDH key exchange + ChaCha20
  • Auto-deletion: Messages deleted after TTL expires
  • Size Limit: 140 bytes maximum
  • Privacy: Only recipient can decrypt

Sending Messages

# Send an ephemeral message tos_wallet send_message recipient=bob message="Hello, Bob!" ttl=1000 # TTL range: 100-86400 blocks (~30 min to 3 days)

Reading Messages

# List received messages tos_wallet list_messages page=0 # Read a specific message (auto-decrypts) tos_wallet read_message message_id=<hash>

Encryption Details

Messages are encrypted using ECDH (Elliptic Curve Diffie-Hellman):

  1. Sender derives shared secret from recipient’s public key
  2. Message encrypted with ChaCha20 using derived key
  3. Only recipient’s private key can decrypt
  4. Message expires after TTL blocks
pub struct EphemeralMessagePayload { /// Sender's TNS name hash sender_name_hash: Hash, /// Recipient's TNS name hash recipient_name_hash: Hash, /// Message nonce (for replay protection) message_nonce: u64, /// TTL in blocks ttl_blocks: u32, /// Encrypted content encrypted_content: Vec<u8>, /// Decryption handle for recipient receiver_handle: DecryptHandle, }

Smart Contract Integration

Syscalls

While TNS is primarily used via wallet and RPC, smart contracts can verify name ownership:

use tako_sdk::*; fn verify_name_ownership(user: &Address, expected_name_hash: &Hash) -> bool { // Get name hash registered by this address let name_hash = get_name_hash_by_account(user); match name_hash { Some(hash) => hash == *expected_name_hash, None => false } }

Data Structures

On-Chain Storage

// Name Registry Columns NameHashToAccount: {blake3(name)} => PublicKey AccountHasName: {PublicKey} => blake3(name) // Ephemeral Messages EphemeralMessages: {recipient_hash}{created_topo}{msg_id} => MessageData MessageExpiry: {expire_topo}{msg_key} => () MessageIdIndex: {msg_id} => expire_topo

RegisterNamePayload

pub struct RegisterNamePayload { /// Username (without @tos.network suffix) name: String, } // Serialization: 1 byte length + name bytes // Max size: 1 + 64 = 65 bytes

Transaction Types

TransactionType IDDescription
RegisterName21Register a TNS name
EphemeralMessage22Send an ephemeral message

Security Considerations

Name Privacy

  • Names are stored as blake3 hashes on-chain
  • Cannot reverse the hash to get the original name
  • Name lookup requires knowing the name first

Anti-Phishing Measures

  • ASCII Only: Non-ASCII characters rejected (prevents homoglyph attacks)
  • Reserved Names: Common admin names blocked
  • Normalization: Automatic lowercase conversion
  • Separator Rules: Prevents confusing names like alice..bob

Unicode Homoglyph Protection: TNS only allows ASCII characters to prevent attacks where similar-looking Unicode characters (like Cyrillic “a”) could impersonate legitimate names.

Message Security

  • End-to-end encrypted (sender to recipient only)
  • Replay protection via message nonce
  • Auto-deletion ensures message privacy
  • No message content stored in plaintext

Future Upgrades (V2)

FeatureDescription
Name ModificationChange name once per year
Subdomainsteam.alice@tos.network
Profile DataLink metadata to names
Name MarketplaceTransfer/sell names

V2 features require a protocol upgrade. The current V1 implementation does not support name changes or transfers.

Wallet Command Summary

CommandDescriptionExample
register_nameRegister a TNS nameregister_name name=alice
resolve_nameResolve name to addressresolve_name name=bob
send_messageSend ephemeral messagesend_message recipient=bob message="Hi" ttl=1000
list_messagesList received messageslist_messages page=0
read_messageRead message detailsread_message message_id=<hash>
transferTNS-aware transfertransfer address=bob@tos.network amount=100
transfer_allTNS-aware full transfertransfer_all address=alice@tos.network

See Also

Last updated on