# Tags

## What are Tags?

Tags are content trackers that can hold any string based content, as well as providing a way to store a checksum of the content and the algorithm used to produce the checksum. Tags can also easily be updated to change the underlying content with the option of updating the checksum and algorithm fields if necessary.

In short, Tags allow developers to attach specific, verifiable content to Items that will travel with changes in Item ownership. Anyone can verify the contents of a tag by running the defined checksum algorithm over the content and comparing to the checksum stored on the tag.

## Tag Name Standards

The following are existing tag name standards in use throughout Marble.

| Name     | Description                                            |
| -------- | ------------------------------------------------------ |
| image    | An item's image that can be consumed by a frontend UI. |
| title    | A title that identifies the item.                      |
| subtitle | A short tweet-length subtitle for the item.            |

## Shared Tags

The Tags layer also includes Shared Tags, which funciton the same as normal Item Tags but are assigned to an entire group instead of an individual item. Use Shared Tags to handle Tags that all items inherit or to save on RAM costs.

## Tag Locks

Tags can also be **locked**, which prevents any further changes to the given Tag and effectively makes it immutable. Once locked, the tag can never become unlocked again.

## Table Breakdown

**Table Name:** `tags`

**Table Scoping:** `item.serial`

| Field Name | Field Type | Description                                       |
| ---------- | ---------- | ------------------------------------------------- |
| tag\_name  | name       | Tag Name Identifier                               |
| content    | string     | Tag Content (JSON, REST Endpoint, IPFS CID, etc.) |
| checksum   | string     | Checksum of content                               |
| algorithm  | string     | Algorithm used to produce checksum                |
| locked     | bool       | Tag is locked if true                             |

#### No extra indices.

## Create a New Tag

To create a new tag for an Item call the `newtag()` action.

**Required Authority:** `group.manager`

{% hint style="info" %}
Note that parameters marked as optional still require the 'null' argument in their place and can't simply be omitted in the transaction.
{% endhint %}

### Action Parameters

| Name      | Type              | Example        | Description                                             |
| --------- | ----------------- | -------------- | ------------------------------------------------------- |
| serial    | uint64\_t         | 5              | The serial number of the Item to tag.                   |
| tag\_name | name              | tag1           | The name of the new tag.                                |
| content   | string            | "content here" | The content of the tag (JSON, Markdown, IPFS CID, etc). |
| checksum  | optional\<string> | "f83jfya7"     | Checksum of the content field.                          |
| algorithm | optional\<string> | "sha256"       | The algorithm used to produce the checksum.             |
| shared    | bool              | false          | Create shared tag if true.                              |

### Examples

{% tabs %}
{% tab title="Cleos" %}

```
cleos push action {account} newtag '[ {params} ]' -p {manager}
```

{% endtab %}

{% tab title="Marble CLI" %}

```
marble make tag ...
```

{% endtab %}
{% endtabs %}

## Update a Tag

To update a tag call the `updatetag()` action.

**Required Authority:** `group.manager`

### Action Parameters

| Name           | Type              | Example            | Description                                           |
| -------------- | ----------------- | ------------------ | ----------------------------------------------------- |
| serial         | uint64\_t         | 5                  | The serial number of the Item with the tag to update. |
| tag\_name      | name              | tag1               | The name of the tag to update.                        |
| new\_content   | string            | "new content here" | The new content for the tag.                          |
| new\_checksum  | optional\<string> | "mfau72n4"         | The checksum of the new content.                      |
| new\_algorithm | optional\<string> | "md5"              | The algorithm used to produce the checksum.           |
| shared         | bool              | true               | Update a shared tag if true.                          |

### Examples

{% tabs %}
{% tab title="Cleos" %}

```
cleos push action {account} updatetag '[ {params} ]' -p {manager}
```

{% endtab %}

{% tab title="Marble CLI" %}

```
marble modify tag ...
```

{% endtab %}
{% endtabs %}

## Lock a Tag

Lock a tag and prevent future updates with the `locktag()` action.

**Required Authority:** `group.manager`

### Action Parameters

| Name           | Type | Example   | Description                                      |
| -------------- | ---- | --------- | ------------------------------------------------ |
| group\_name    | name | testgroup | The name of the group with the behavior to lock. |
| behavior\_name | name | transfer  | The name of the behavior to lock.                |
| shared         | bool | true      | Lock a shared tag if true.                       |

### Examples

{% tabs %}
{% tab title="Cleos" %}

```
cleos push action {account} lockbhvr '[ ... ]' -p {account}
```

{% endtab %}

{% tab title="Marble CLI" %}

```
marble lock ...
```

{% endtab %}
{% endtabs %}

## Remove a Tag

To remove a tag from an Item call the `rmvtag()` action.

**Required Authority:** `group.manager`

### Action Parameters

| Name      | Type      | Example        | Description                          |
| --------- | --------- | -------------- | ------------------------------------ |
| serial    | uint64\_t | 5              | The serial of the Item with the Tag. |
| tag\_name | name      | tag1           | The name of the tag to remove.       |
| memo      | string    | "Removing Tag" | An optional memo field.              |
| shared    | bool      | false          | Remove a shared tag if true.         |

### Examples

{% tabs %}
{% tab title="Cleos" %}

```
cleos push action {account} rmvtag '[ ... ]' -p {manager}
```

{% endtab %}

{% tab title="Marble CLI" %}

```
marble remove tag ...
```

{% endtab %}
{% endtabs %}
