# MetaID Envelope

### Envelope

The MetaID content is entirely on-chain, and the MetaID envelope format currently supports two schemes:

#### 1. Taproot-Script:

By utilizing the Taproot-Script "commit/reveal" scheme, the MetaID envelope is placed in the Taproot script of the input, containing various operations that can be legally executed on MetaID. The convention is to use `OP_FALSE OP_IF ... OP_ENDIF` to place any non-executable content in the Taproot spending script. The byte " `metaid` " (`6D6574616964` in hexadecimal) is used to identify the envelope as a MetaID protocol.

Taproot-Script Envelope format:

```jsx
OP_FALSE
OP_IF
	<metaid_flag>
	<operation>
	<path>
	<encryption>
	<version>
	<content-type>
	<payload>
OP_ENDIF
```

#### 2. Locking-Script:

By utilizing the OpReturn opcode, data is placed after it. The MetaID envelope is placed in the Locking-Script of the transaction output, containing various operations that can be legally executed on MetaID. The convention is to use `OP_RETURN` to place any non-executable content in the locking output script. The byte " `metaid` " (`6D6574616964` in hexadecimal) is used to indicate that the envelope belongs to the MetaID protocol.

Locking-Script Envelope format:

```jsx
OP_0
OP_RETURN
	<metaid_flag> 
	<operation>
	<path>
	<encryption>
	<version>
	<content-type>
	<payload>
```

The envelope must appear after `OP_RETURN` in the output script and at index 1 of the output. The first satoshi of the UTXO at index 0 is used to carry the envelope content.

<figure><img src="/files/fFEod1eJiTykYrherOwN" alt=""><figcaption></figcaption></figure>

**Note: If both Taproot-Script and Data-script envelopes exist in the same transaction, the Taproot-Script format takes precedence.**


---

# 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/metaid-envelope.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.
