Skip to main content
TON DNS maps human-readable domains such as example.ton or username.t.me to on-chain values: wallet addresses, TON Site ADNL addresses, TON Storage bags, and subdomain resolvers. Each domain is an NFT item whose owner controls its DNS records. This section covers resolving domains, reading records from a DNS item, updating records, and resolving a site’s ADNL address to network endpoints via DHT.

Resolve a Domain

Use client.dnsresolve() to resolve a domain to a record of a specific category. Resolution starts from the DNS root contract (taken from blockchain config parameter 4) and follows next-resolver records automatically, so .ton domains, .t.me domains, and subdomains all work. Parameters:
  • domain — domain name to query, e.g. "example.ton" or "username.t.me"; pre-encoded DNS bytes are also accepted (str | bytes).
  • category — DNS record type to retrieve (DNSCategory): WALLET, SITE, STORAGE, DNS_NEXT_RESOLVER, TEXT, or ALL (category 0, requests all records and returns a raw Cell).
  • dns_root_address — custom DNS root address; defaults to the one from blockchain config (Address, optional).
The method returns a parsed record object (DNSRecordWallet, DNSRecordSite, etc.), a raw Cell if the record cannot be parsed, or None if the record is not set.

Get DNS Records

To read all records stored in a domain, load the DNS item contract with TONDNSItem.from_address() and iterate over its dns_records dictionary. Each value is a typed record object; check its type to interpret the value correctly.

Set DNS Records

To update a record, send a ChangeDNSRecordBody to the DNS item contract from the wallet that owns the domain. Each category expects a specific record type and value type:
The transaction must be sent from the wallet that owns the DNS item, otherwise the contract rejects the change.
The example below sets a wallet record; substitute the category and record type from the table to set other records.

Resolve ADNL Address via DHT

A TON Site’s SITE record contains an ADNL address, not an IP address. To find the actual network endpoints, query the TON DHT with DhtNetwork, initialized from the network’s global config via from_network_config(). find_addresses() returns the address list and the public key of the node behind the ADNL address, and raises DhtValueNotFoundError (from tonutils.exceptions) if the ADNL address is not found in the DHT.
DNS resolution issues multiple sequential get-method calls (one per resolver hop plus a config fetch), so the example lowers the client’s request rate with rps_limit=1, rps_period=1.2 to stay within the free Toncenter rate limits.

DNS Examples

Full runnable scripts for all DNS operations on GitHub.