# 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="https://1852888944-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQqzh03Cj3B0aOuGYLJKs%2Fuploads%2FkprdpfDzZ8RVvKeLkQvi%2Fimage.png?alt=media&#x26;token=7d69c385-89be-433a-97a7-c7f3cd552a6e" alt=""><figcaption></figcaption></figure>

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