# PIN Data Structure

The MAN indexer extracts MetaID protocol data from the reveal scripts of Taproot transactions. For detailed protocol information, please refer to the MetaID Specification section.

### PIN Data Structure

```go
type PinInscription struct {
	Id                 string `json:"id"`
	Number             int64  `json:"number"`
	RootTxId           string `json:"rootTxId"`
	MetaId             string `json:"metaid"`
	Address            string `json:"address"`
	CreateAddress      string `json:"createAddress"`
	Output             string `json:"output"`
	OutputValue        int64  `json:"outputValue"`
	Timestamp          int64  `json:"timestamp"`
	GenesisFee         int64  `json:"genesisFee"`
	GenesisHeight      int64  `json:"genesisHeight"`
	GenesisTransaction string `json:"genesisTransaction"`
	TxIndex            int    `json:"txIndex"`
	TxInIndex          uint32 `json:"txInIndex"`
	TxInOffset         uint64 `json:"txInOffset"`
	Operation          string `json:"operation"`
	Path               string `json:"path"`
	ParentPath         string `json:"parentPath"`
	OriginalPath       string `json:"originalPath"`
	Encryption         string `json:"encryption"`
	Version            string `json:"version"`
	ContentType        string `json:"contentType"`
	ContentTypeDetect  string `json:"contentTypeDetect"`
	ContentBody        []byte `json:"contentBody"`
	ContentLength      uint64 `json:"contentLength"`
	ContentSummary     string `json:"contentSummary"`
	Status             int    `json:"status"`
	OriginalId         string `json:"originalId"`
	IsTransfered       bool   `json:"isTransfered"`
	Preview            string `json:"preview"`
	Content            string `json:"content"`
	Pop                string `json:"pop"`
}
```

### PIN Indexing Rules

#### General

1. **Flag Recognition:** The flag is `metaid`.
2. **Case Sensitivity:** Case insensitive. The indexer can store all data in lowercase.

#### Operation

1. The `pinid` of an `init` type PIN is a user's `MetaID`.
2. `init` and `create` operations follow the first-come, first-served principle.
3. Within the same block, the order of `init` and `create` operations is not distinguished. The indexer should process `init` type PINs first to establish the `metaid`.

#### Path

1. For the same path, `init` and `create` PINs are indexed by the oldest entry, while `modify` and `revoke` operations consider the most recent entry.
2. `modify` and `revoke` operations must act on already included PINs. These operations are valid only for already included PINs, even within the same block.
3. Non-`init` PIN paths must fall within the following default paths for a MetaID:

   (1) /info

   (2) /protocols

   (3) /file

   (4) /ft

   (5) /nft

   (6) /follow
4. Paths for `modify` and `revoke` operations should specify the target PIN using `@pinId`.

### PIN Status Codes

| Status Codes | Describe                                                                                                                                         |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| 0            | Normal PIN                                                                                                                                       |
| -1           | PIN being revoked                                                                                                                                |
| 1            | PIN being modified                                                                                                                               |
| -101         | Target PIN's block height ≤ Current PIN's block height                                                                                           |
| -102         | Target PIN has already been transferred                                                                                                          |
| -201         | PIN being modified, correct format, but the PINId in @+PINID does not exist (confirmed PIN)                                                      |
| -202         | PIN being modified, correct format, but the address initiating the modify does not exist                                                         |
| -203         | PIN being modified, correct format, address initiating the modify exists, but the target PIN's address is not equal to the current PIN's address |
| -204         | Target PIN already has a modify (status code 1)                                                                                                  |
| -205         | Target PIN's Operation is init                                                                                                                   |
| -301         | PIN being revoked, correct format, but the PINId in @+PINID does not exist                                                                       |
| -302         | PIN being revoked, correct format, but the address initiating the revoke does not exist                                                          |
| -303         | PIN being revoked, correct format, address initiating the revoke exists, but the target PIN's address is not equal to the current PIN's address  |
| -304         | Target PIN has already been revoked (status code -1)                                                                                             |
| -305         | PIN being revoked, correct format, but the target PIN's Operation is init or the target PIN's Path is **/info/**                                 |

For more information, please refer to the MAN source code:

{% embed url="<https://github.com/metaid-developers/man-indexer>" %}
