<?xml version="1.0" encoding="utf-8"?>
<!-- 
     draft-chins-dnsop-web3-wallet-mapping-02
     Documentation is at https://authors.ietf.org/en/templates-and-schemas
-->
<?xml-model href="rfc7991bis.rnc"?>  <!-- Required for schema validation and schema-aware editing -->
<!-- <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?> -->
<!-- This third-party XSLT can be enabled for direct transformations in XML processors, including most browsers -->


<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<!-- If further character entities are required then they should be added to the DOCTYPE above.
     Use of an external entity file is not recommended. -->

<rfc
  xmlns:xi="http://www.w3.org/2001/XInclude"
  category="std"
  docName="draft-chins-dnsop-web3-wallet-mapping-03"
  ipr="trust200902"
  obsoletes=""
  updates=""
  submissionType="IETF"
  xml:lang="en"
  consensus="true"
  version="3">
  <front>
    <title abbrev="Abbreviated Title">DNS to Web3 Wallet Mapping</title>

    <seriesInfo name="Internet-Draft" value="draft-chins-dnsop-web3-wallet-mapping-03"/>
   
    <author fullname="Shay Chin" initials="SC" role="editor" surname="Chin">
      <!-- [CHECK]
             * initials should not include an initial for the surname
             * role="editor" is optional -->
    <!-- Can have more than one author -->
      
    <!-- all of the following elements are optional -->
      <organization>D3 Global Inc</organization>
      <address>
        <email>shay@d3.com</email>  
      </address>
    </author>
   
    <date year="2025"/>
    <!-- On draft subbmission:
         * If only the current year is specified, the current day and month will be used.
         * If the month and year are both specified and are the current ones, the current day will
           be used
         * If the year is not the current one, it is necessary to specify at least a month and day="1" will be used.
    -->

    <area>General</area>
    <workgroup>Internet Engineering Task Force</workgroup>
    <!-- "Internet Engineering Task Force" is fine for individual submissions.  If this element is 
          not present, the default is "Network Working Group", which is used by the RFC Editor as 
          a nod to the history of the RFC Series. -->

    <keyword>Web3 Wallet DNS Mapping</keyword>
    <!-- [REPLACE/DELETE]. Multiple allowed.  Keywords are incorporated into HTML output files for 
         use by search engines. -->

    <abstract>
      <t>This document proposes an implementation standard for mapping wallets to domain names using the new WALLET RRType, allowing for TXT record fallback while the WALLET RRType propagates through DNS providers.  The goal is to provide a secure and scalable and unbiased way to associate wallets with domain names, enabling seamless lookup as well as suggesting required authentication mechanism.  The proposal relies on DNSSEC or security successors to ensure trust and security.</t>
    </abstract>
 
  </front>

  <middle>
    <section>
      <name>Introduction</name>
      <t>There is fragmentation in the mapping of Web3 Wallets to Domain Names <xref target="RFC1034"/>.  This document puts forth an implementation standard to map Web3 Wallet addresses to Domain Names, as well as investigates the associated security and technical concerns.</t>
      <t>As the use of digital wallets and online services grows, the need for a standardized way to lookup wallet addresses in an human readable format becomes increasingly important. This proposal aims to provide a solution that is easy to implement, scalable, unbiased, standardized and secure.</t>
      <t>The proposed notational implementation involves using the DNS WALLET RRtype <xref target="WALLET-IANA-RRTYPE"/> to map a domain name on the Global DNS system to wallet address information. The WALLET record will contain a object that maps the wallet address to a registered Namespace <xref target="CHAIN-AGNOSTIC-NAMESPACES"/> and the registered coin type token <xref target="SLIP-0044"/> or <xref target="CAIP-2"/>.  This implementation will handle multiple wallet addresses and chains, defaults, as well as defining a heirarchy to deterministicly be able to find the appropriate wallet address.  It is assumed that the record will be part of a DNSSEC <xref target="RFC4033"/> <xref target="RFC9364"/> signed zonefile or its security successors, and that users of this service will verify the signatures to ensure that the record has been returned without alteration in flight.  This implementation proposal is evolutionary to the the description in <xref target="WALLET-IANA-RRTYPE"/> because it defines standards for coin names, defaults, and conditions for rejection, in order to have consistant usages.</t>
      <t>We also propose a fallback TXT record "_w3addr" which will be a backup for the WALLET RRtype and CAN duplicate the WALLET RRtype entries.  This is intended to be a temporary measure while DNS Provider's UIs support this RRType <xref target="RFC3597"/>.</t>
      
      <section>
        <name>Requirements Language</name>
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
          "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT
          RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
          interpreted as described in BCP 14 <xref target="RFC2119"/>
          <xref target="RFC8174"/> when, and only when, they appear in
          all capitals, as shown here.</t>
      </section>
    </section>

    <section>
      <name>Terminology</name>
      <t>This document will refer to Domain Name terminology <xref target="RFC9499"/>.</t>
    </section>
    
    <section>
      <name>Domain to Wallet Mapping</name>
      <section>
        <name>Record Format</name>
        <t>The WALLET or TXT record SHALL have the following format:</t>
        <sourcecode>
          <![CDATA[
    @ IN WALLET "namespace:reference:address1"
    @ IN TXT    "namespace:reference:address1"
          ]]>
        </sourcecode>
        <dl newline="true">
            <dt>@</dt>
            <dd>is the address</dd>
            <dt>IN</dt>
            <dd>is the class of the record</dd>
            <dt>WALLET / TXT</dt>
            <dd>is the type of the record</dd>
            <dt>namespace:reference:address1</dt>
            <dd>is the value of the record</dd>
        </dl>
      </section>

      <section>
        <name>Grammar for the record in EBNF format</name>
        <sourcecode>
          <![CDATA[
   item = namespace ":" (coin_name | reference) ":" address
   namespace = (letter | digit | "-"){3,8}
   coin_name = (letter | digit | "_"){1,32}
   address =  ( letter | digit | "-" | "." | "%" ){1,128}
   letter = "A" | "B" | "C" | "D" | "E" | "F" | "G"
          | "H" | "I" | "J" | "K" | "L" | "M" | "N"
          | "O" | "P" | "Q" | "R" | "S" | "T" | "U"
          | "V" | "W" | "X" | "Y" | "Z" | "a" | "b"
          | "c" | "d" | "e" | "f" | "g" | "h" | "i"
          | "j" | "k" | "l" | "m" | "n" | "o" | "p"
          | "q" | "r" | "s" | "t" | "u" | "v" | "w"
          | "x" | "y" | "z"
   digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
          ]]>
        </sourcecode>

        <dl newline="true">
          <dt>item</dt>
          <dd>represents a namespace-reference-address tuple</dd>
          <dt>namespace</dt>
          <dd>covers a class of similar blockchains such as "Solana" or "eip155" specified by Chain Agnostic Namespaces <xref target="CHAIN-AGNOSTIC-NAMESPACES"/>.  This is NOT case sensitive.</dd>
          <dt>coin_name</dt>
          <dd>represents the Symbol of a Coin Type represented in <xref target="SLIP-0044"/>.  This is NOT case sensitive.</dd>
          <dt>reference</dt>
          <dd>a way to identify a blockchain within a namespace.  As an example this would be chain ID within eip155 ecosystem as referenced by <xref target="CAIP-2"/>.  This is NOT case sensitive.</dd>
          <dt>address</dt>
          <dd>represents the public wallet address associated with a coin (e.g., "0xabcdefg", "0x12345", etc).  This CAN be case sensitive as required by the wallet addressing scheme</dd>
        </dl>
        <t>This grammar can be used to parse the input string and extract the chain identifier and addresses.</t>
      </section>

      <section>
        <name>Example</name>
        <t>Suppose a user wants to map their wallet with the public keys to the domain "example.com" using the registered coin type tokens BTC, SOL and and Ethereum mainnet chain id. The WALLET record in the zone would be:</t>
        <sourcecode><![CDATA[
        @ IN WALLET "bip122:BTC:0x1234567890abcd"
        @ IN WALLET "solana:SOL:0x567890123456789"
        @ IN WALLET "eip155:1:0x987654321098765"      
        ]]></sourcecode>
      </section>

      <section>
        <name>TXT Record Example</name>
        <t>Suppose a user wants to map their wallet with the public keys to the domain "example.com" using the registered coin type tokens BTC, SOL and Ethereum mainnet chain id using a TXT record. The TXT record in the zone would be:</t>
        <sourcecode><![CDATA[
       _waddr IN TXT "bip122:BTC:0x1234567890abcd"
       _waddr IN TXT "solana:SOL:0x567890123456789"
       _waddr IN TXT "eip155:1:0x987654321098765"
        ]]></sourcecode>
      </section>
      
      <section>
        <name>Multiple Records</name>
        <t>To support multiple coins, multiple coin:address pairs will each be represented by their own WALLET record. There is no guarantees on ordering the records so overlapping records MAY be ordered at the resolver's discretion.  In the event of duplicate coin types it is RECOMMENDED that multiple records be returned deduplicated for identical addresses.</t>
      </section>

      <section>
        <name>Implementation</name>
        <t>Wallet resolver implementations of this RFC SHALL:</t>
        <ol>
          <li>Support the creation and retrieval of WALLET records for any given level of the DNS system.</li>
          <li>Validate the records as being properly signed by DNSSEC or its successors.</li>
          <li>Provide the wallet's address for a human readable domain name.</li>
          <li>Provide an authoritative NXADDR if no address can be found.</li>
        </ol>
      </section>
    </section>
    
    <section anchor="Security">
      <name>Security Considerations</name>
      <t>To ensure the security of the mapping, the following measures will be taken:</t>
      <ol>
        <li>The WALLET RRtype record SHALL BE stored in a secure location, such as a DNSSEC-signed zone.</li>
        <li>The implementation SHALL validate the DNSSEC record or its IETF approved successors.</li>
        <li>The wallet record SHALL be protected from replay attacks via DNSSEC time invalidation (or approved successors).</li>
      </ol>

      <t>The WALLET RRtype might not be available throughout entire end to end DNS infrastructure.  In the event that DNSSEC is not supported end to end, a wallet resolver MUST indicate that the wallet address is informational only and CANNOT be trusted.</t>

      <t>If the source of the DNS zone is compromised, the wallet address mapping is compromised.  It is imperative that this not occur for both DNS stability, as well as wallet mapping Notationaly using DNS.</t>
    </section>

    
    <section anchor="IANA">
    <!-- All drafts are required to have an IANA considerations section. See RFC 8126 for a guide.-->
      <name>IANA Considerations</name>
      <t>This proposal does not require IANA changes.</t>
    </section>
    
    <!-- NOTE: The Acknowledgements and Contributors sections are at the end of this template -->
  </middle>

  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.1034.xml"/> 
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.3597.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4033.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9364.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9499.xml"/>
        <!-- The recommended and simplest way to include a well known reference -->
        
      </references>
      <references>
        <name>Informational References</name>
        <reference anchor="SLIP-0044" target="https://raw.githubusercontent.com/satoshilabs/slips/master/slip-0044.md">
          <front>
            <title>Registered coin types for BIP-0044</title>
            <author/>
            <date/>
          </front>
        </reference>
        <reference anchor="CAIP-2" target="https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md">
          <front>
            <title>CAIP-2: Blockchain ID Specification</title>
            <author initials="S" surname="Warta"></author>
            <author surname="ligi"></author>
            <author initials="P" surname="Gomes"></author>
            <author initials="A" surname="Herzog"></author>
            <date>December 2019</date>
          </front>
        </reference>
        <reference anchor="CHAIN-AGNOSTIC-NAMESPACES" target="https://namespaces.chainagnostic.org/">
          <front>
            <title>Chain Agnostic Namespaces</title>
            <author/>
            <date/>
          </front>
        </reference>
        <reference anchor="WALLET-IANA-RRTYPE" target="https://www.iana.org/assignments/dns-parameters/WALLET/wallet-completed-template">
          <front>
            <title>Wallet Completed Template</title>
            <author/>
            <date>2024-06-24</date>
          </front>
        </reference>
      </references>
    </references>
    
    <section anchor="Appendix">
      <name>Example code</name>
      <t>Here is an example of how to create and retrieve a WALLET records using the domain name:</t>
      <sourcecode><![CDATA[
      import dns.resolver.wallet
      # Retrieve the WALLET record
      record = dns.resolveWallet("example.com", "BTC")

      print(record.value)  # Output: "0x1234567890abcdef"
      xs]]></sourcecode>
    </section>

    <section anchor="Contributors" numbered="false">
      <name>Contributors</name>
      <t>Thanks to all of the contributors for contributions to security and clarity.</t>
      <contact fullname="Yevhenii Andrushchak"><address><email>yevhenii@d3.com</email></address></contact>
      <contact fullname="Kai Sung"><address><email>kai@d3.com</email></address></contact>
    </section>

    <section anchor="Acknowledgements" numbered="false">
      <name>Acknowledgements</name>
      <t>Reviewed by:</t>
      <contact fullname="Jothan Frakes"><address><email>jothan@frakes.com</email></address></contact>
    </section>
    
    
 </back>
</rfc>
