EIPs Explained

ERC-7529 · Draft · ERC · 2023-09-30

ERC-7529: Contract Discovery and eTLD+1 Association

A draft standard that links smart contracts to a company's web domain by cross-checking a DNS TXT record listing the contracts against a domain list stored in each contract, so wallets can detect impostor tokens.

What problem does it solve?

Anyone can deploy a token called "USD Coin" or an NFT collection claiming to be from a famous brand. Wallets and marketplaces have no simple, open way to check that a contract really belongs to the company behind a given website, and users have no standard way to search for "the contracts of example.com".

ERC-7529 reuses a trick the web already relies on for email (SPF, DKIM) and domain verification: a TXT record in DNS. Because browsers can now query DNS directly over HTTPS (DoH, RFC 8484), a web app or wallet extension can read that record itself rather than trusting a third-party lookup service.

How it works

Association is two-sided, and both sides must agree:

  1. DNS side. The owner of an eTLD+1 domain (the registrable domain, such as example.com or sussex.ac.uk) publishes a TXT record:
    • host: ERC-7529.<chain_id>._domaincontracts.<domain>, with the chain id in decimal (1 for mainnet)
    • value: a comma-separated list of contract addresses
  2. Contract side. Each contract stores mapping(bytes32 => bool) domains keyed by keccak256 of the domain string, with checkDomain(domain), and access-controlled addDomain / removeDomain. Optional AddDomain / RemoveDomain events let clients discover which domains a contract claims.

A client starting from a domain fetches the TXT record and calls checkDomain on each listed address. A client starting from a contract reads its events, fetches the TXT records for those domains, and confirms the contract address appears there. Faking an association would require control of both the domain's DNS and the contract's admin key.

Sample code

Verifying a domain's contracts from a browser with DoH and ethers v6:

import { Contract, JsonRpcProvider, getAddress } from "ethers";

async function verifyDomain(domain: string, chainId: number, provider: JsonRpcProvider) {
  const name = `ERC-7529.${chainId}._domaincontracts.${domain}`;
  const res = await fetch(
    `https://cloudflare-dns.com/dns-query?name=${name}&type=TXT`,
    { headers: { Accept: "application/dns-json" } },
  );
  const json = await res.json();
  const addresses: string[] = (json.Answer ?? [])
    .flatMap((a: { data: string }) => a.data.replace(/"/g, "").split(","))
    .map((s: string) => s.trim())
    .filter(Boolean);

  const abi = ["function checkDomain(string domain) view returns (bool)"];
  const results: Record<string, boolean> = {};
  for (const addr of addresses) {
    const c = new Contract(getAddress(addr.toLowerCase()), abi, provider);
    results[addr] = await c.checkDomain(domain).catch(() => false);
  }
  return results; // true = both DNS and contract agree
}

Things to know

  • Status: Draft.
  • Only the eTLD+1 counts. Subdomains such as app.example.com are not separately associated; resolving the eTLD+1 correctly needs a Public Suffix List.
  • Security rests partly on DNS: domain hijacking or a compromised DNS account weakens it, though an attacker would also need the contract's admin rights to create a false match.
  • addDomain and removeDomain must be properly access-controlled; the reference implementation uses OpenZeppelin onlyRole(DEFAULT_ADMIN_ROLE).
  • The spec recommends ERC-1191 chain-aware checksums in the TXT record. Many tools only produce EIP-55 checksums, so compare addresses case-insensitively, as in the sample.
  • TXT record size limits vary by DNS provider; multiple TXT records under the same host are allowed and returned together.

#dns #identity #verification #wallets #anti-phishing

Details

Authors
Todd Chapman (@tthebc01), Charlie Sibbach <[email protected]>, Sean Sing (@seansing)
Status
Draft
Type
Standards Track / ERC
Created
2023-09-30
Requires

Machine-readable: Markdown · JSON