# Behaviors

## What is a Behavior?

A Behavior is a specific action that an individual Item may perform. Items follow the behavior rules set by their respective groups.&#x20;

For example, if an Item belongs to a group whose `transfer` behavior is set to false, then the Item is not transferrable. If the group manager were to activate transferability with the `toggle()`action, the Item would become transferrable.

## Behaviors

The following behaviors are created for every group by default. Group behaviors apply to all the Items in a given group, and behaviors can be added, removed, or toggled on and off by the group manager.

| Name     | Default | Description                                                                        |
| -------- | ------- | ---------------------------------------------------------------------------------- |
| mint     | true    | Allows Items to be created with the `mintitem()` action.                           |
| transfer | true    | Allows Item ownership to be transferred with the `transferitem()` action.          |
| activate | false   | Allows Items to be activated with the `activateitem()` action.                     |
| reclaim  | false   | Allows Items to be reclaimed by the group manager with the `reclaimitem()` action. |
| consume  | false   | Allows Items to be consumed by the item owner with the `consumeitem()` action.     |
| destroy  | true    | Allows Items to be destroyed by the group manager with the `destroyitem()` action. |

## Behavior Locking

By default all behaviors are **unlocked** meaning the group manager can individually toggle them on or off at any time. Group managers may also choose to **lock** behaviors in a specific state to ensure immutability.

## Table Breakdown

**Table Name:** `behaviors`

**Table Scope:** `group_name`

**No Additional Indices**

| Name           | Type | Example      | Description            |
| -------------- | ---- | ------------ | ---------------------- |
| behavior\_name | name | transferitem | Name of behavior.      |
| state          | bool | true         | Behavior on/off state. |
| locked         | bool | false        | Behavior lock state.   |

## Toggle a Behavior

Toggle a behavior on or off with the `toggle()` action.

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

### Action Parameters

| Name           | Type | Example      | Description                            |
| -------------- | ---- | ------------ | -------------------------------------- |
| group\_name    | name | testgroup    | Name of group with behavior to toggle. |
| behavior\_name | name | transferitem | Name of behavior to toggle on or off.  |

### Examples

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

```
cleos push action {account} toggle '[{params}]'
```

{% endtab %}

{% tab title="Marble CLI" %}

```
marble ...
```

{% endtab %}
{% endtabs %}

## Lock a Behavior

Behaviors can be locked with the `lockbhvr()` action.

{% hint style="warning" %}
Locking a behavior is an irreversible action. Please be sure the locked behavior is in the desired state.
{% endhint %}

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

### Action Parameters

| Name           | Type | Example   | Description                                  |
| -------------- | ---- | --------- | -------------------------------------------- |
| group\_name    | name | testgroup | Name of the group with the behavior to lock. |
| behavior\_name | name | transfer  | Name of the behavior to lock.                |

### Examples

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

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

{% endtab %}

{% tab title="Marble CLI" %}

```
marble ...
```

{% endtab %}
{% endtabs %}

## Add a New Behavior

New behaviors can be added to a group with the `addbehavior()` action.

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

### Action Parameters

| Name           | Type | Example   | Description                        |
| -------------- | ---- | --------- | ---------------------------------- |
| group\_name    | name | testgroup | Name of group to receive behavior. |
| behavior\_name | name | freeze    | Name of new behavior.              |
| initial\_state | bool | true      | Initial state of new behavior.     |

### Examples

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

```
cleos push action {account} addbehavior '[{params}]'
```

{% endtab %}

{% tab title="Marble CLI" %}

```
marble ...
```

{% endtab %}
{% endtabs %}

## Remove a Behavior

Existing behaviors can be removed with the `rmvbehavior()` action.

Required Authority: group.manager

### Action Parameters

| Name           | Type | Example   | Description                            |
| -------------- | ---- | --------- | -------------------------------------- |
| group\_name    | name | testgroup | Name of group with behavior to remove. |
| behavior\_name | name | freeze    | Name of behavior to remove.            |

### Examples

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

```
cleos push action {account} rmvbehavior '[{params}]'
```

{% endtab %}

{% tab title="Marble CLI" %}

```
marble ...
```

{% endtab %}
{% endtabs %}
