> For the complete documentation index, see [llms.txt](https://docs.metaid.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metaid.io/metaid-specification/metaid-envelope.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.metaid.io/metaid-specification/metaid-envelope.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
