# MetaName

## About

### **Introduction**

To build a more comprehensive ecosystem, the MetaID-v2 protocol utilizes MetaName as its domain name system. Anyone can register their own domain name and namespace and use its features.

## Spec

MetaName defines the domain name specification for MetaID-v2, with the agreed `path` being `/metaname/{namespace}`.

#### Register Name

Registering a new domain name follows the principle of **First is first** and is temporarily indexed on BTC. Anyone can easily register a MetaName on the MetaID-v2 protocol. According to the MetaID-v2 protocol, use `operation` as `create` and `path` as `/metaname/{namespace}` to declare any namespace, such as `metaid/ord/sats/btc`. For example, registering `alice.metaid` would look like this:

```json
OP_FALSE
OP_IF
   metaid                
   create                
   /metaname/metaid  //namespace: metaid/ord/sats/btc          
   0                     
   OP_0                  
   Application/json            
   {
      "name": "alice",
      "rev": "",
      "relay": "",
      "metadata": ""
   }                // MetaName payload (example)
OP_ENDIF
```

MetaName allows users to set `rev`, `relay`, and `metadata` parameters during registration:

```json
{
  "name": "alice",
  "rev": "",
  "relay": "",
  "metadata": ""
}
```

| **Key**  | **Required?** | **Type** | **Expected**   | **Description**                                                                                                                                                                    |
| -------- | ------------- | -------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name     | Y             | String   | MNS name       | The domain name set during registration. Namespace does not need to be added. See specific [restrictions](https://www.notion.so/MetaName-12ee16594dde806caecfef37a31c2df7?pvs=21). |
| rev      | N             | String   | address format | The address corresponding to domain resolution.                                                                                                                                    |
| relay    | N             | String   |                | The pointer corresponding to domain resolution.                                                                                                                                    |
| metadata | N             | String   |                | Custom content, suggested to be within 200 characters.                                                                                                                             |

#### **⚠️ Domain Name Restrictions**

* Domain names cannot be duplicated and follow the principle of **First is first**.
* The `operation` must be `create` when registering a domain name.
* Any UTF-8 character is valid.
* All domain names are automatically converted to lowercase.
* Spaces, periods, and line breaks are not allowed in domain names.

#### Update Name

To update or modify a domain name, use `operation` as `modify` under the rules of MetaID-v2. The `path` must point to the corresponding MetaName's `pinid`, and only the `rev`, `relay`, and `metadata` parameters can be updated.

* Note that `modify` does not affect the `name`.
* The `name` in the payload can be left blank when modifying.

```json
OP_FALSE
OP_IF
   metaid                
   modify                
   @{pinid}         
   0                     
   OP_0                  
   Application/json            
   {
          "rev": "xxx",
          "relay": "xxxxx",
          "metadata": "xxxxxxxx"
   }
OP_ENDIF
```

### Example

#### Registration

MetaName: alice.metaid

```json
OP_FALSE
OP_IF
   metaid                
   create                
   /metaname/metaid  //metaid/ord/sats/btc          
   0                     
   OP_0                  
   Application/json            
   {
          "name": "alice",
          "rev" : "bc1puyjhe7h2crd86qnerjqwmhc55t9zzhacnj4h9ypmclwkgsd4h8eq6xk2ys",
          "relay": "xxx",
          "metadata": ""
   }
OP_ENDIF
```

#### Update

MetaName: alice.metaid

```json
OP_FALSE
OP_IF
   metaid                
   modify                
   @2e9b714d338c47cb4144d9f6986f510f83504ad4158297158b490406e825ff0c         
   0                     
   OP_0                  
   Application/json            
   {
           "rev" : "bc1ppkvfwnw67q4w8pt86l7wr3jkngsyymqucrn6vxak7zpntawm6n6qe2n9ls",
           "relay": "xxx",
           "metadata": ""
   }
OP_ENDIF
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.metaid.io/metaid-specification/metaname.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
