# MetaName

## About

### **Introduction**

为了打造更完整的生态，在MetaID-v2协议上使用MetaName作为域名系统。任何人都可以注册自己的域名和命名空间，并使用其功能。

## Spec

MetaName为MetaID-v2中的域名规范，约定的`path`路径为`/metaname/{namespace}`。

#### Register Name

注册新域名遵循先见原则，即**First is first**，且暂时索引在BTC上。任何人都可以在MetaID-v2协议上简单方便地注册MetaName。按照MetaID-v2协议，使用`operation`为`create`，`path`为`/metaname/{namespace}`，在路径中即可声明任何namespace，比如`metaid/ord/sats/btc` 等等。如下注册一个`alice.metaid`

```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（示例）
OP_ENDIF
```

MetaName允许用户注册时设置`rev/relay/metadata`参数，

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

| **Key**  | **Required?** | **Type** | **Expected**   | **Description**                                                                                                |
| -------- | ------------- | -------- | -------------- | -------------------------------------------------------------------------------------------------------------- |
| name     | Y             | String   | MNS name       | 注册时设置的域名name，不需要添加namespace，具体参考一下[限制](https://www.notion.so/MetaName-12ee16594dde806caecfef37a31c2df7?pvs=21) |
| rev      | N             | String   | address format | 域名解析对应的地址                                                                                                      |
| relay    | N             | String   |                | 域名解析对应的指针                                                                                                      |
| metadata | N             | String   |                | metadata，自定义内容，建议不超过200字符                                                                                      |

#### **⚠️ 域名限制**

* 注册域名不可重复，遵循先见原则，即**First is first**
* 注册域名时operation必须要为create
* 任何 UTF-8 字符均有效
* 所有域名均自动转化为小写
* 域名中不允许有空格，句点和换行符

#### Update Name

通过MetaID-v2的规则，使用operation为modify来修改更新，path需要指向对应的MetaName的`pinid`，且仅对`rev/relay/metadata`参数有效。

* 注意modify对`name`无效
* modify时payload中的`name`可空

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

### Example

#### 注册

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
```

#### 更新

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/zh/metaid-xie-yi-gui-fan/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.
