# Asset

## Create Class

#### Description:

This function creates a new class of assets. Classes being a set that includes related assets or assets that have common characteristics.

#### Previous Steps:

1. [Create an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
2. [Fund an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)

#### Steps:

1. Call the assets/create\_class endpoint with the following request body:

* seed: the seed of the account that will pay for the transaction.&#x20;
* class\_id: the class identifier (must be unique).&#x20;
* owner: the account address that will have ownership of the class.&#x20;
* metadata: additional information about the class.

#### Example Input:

```
{
    "seed": "//Alice",
    "metadata": {
        "userdata": "Type 1"
    },
    "class_id": 1,
    "owner": "5EcFZ4EkYFMYcpJWyjgDde4zG8tVvmdanXeSyNTyD42r552b"
}
```

#### Expected Output:

```
{
    "class_id": 1,
    "who": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
}
```

* class\_id: the class identifier.&#x20;
* who: the account address of the class owner.

## Class Info

#### Description:

This function returns information about a class.

#### Previous Steps:

1. [Create an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
2. [Fund an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
3. [Create a class](#create-class)

#### Steps:

1. Call the assets/class\_info endpoint with the following request body:

* class\_id: the class identifier.

#### Example Input:

```
{
    "class_id": 1
}
```

#### Expected Output:

```
{
    "info": {
        "class_id": 1,
        "owner": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
        "metadata": {
            "userdata": "data"
        }
    }
}
```

* class\_id: the class identifier.&#x20;
* owner: the account address of the class owner.&#x20;
* metadata: additional information about the asset.

## Create

#### Description:

This function creates an asset.

#### Previous Steps:

1. [Create an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
2. [Fund an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
3. [Create a class](#create-class)

#### Steps:

1. Call the assets/create endpoint with the following request body:

* seed: the seed of the account that will pay for the transaction.&#x20;
* class\_id: the class identifier&#x20;
* asset\_id: the asset identifier (must be unique).&#x20;
* account: the account address that will have ownership of the asset.&#x20;
* metadata: additional information about the asset.

#### Example Input:

```
{
    "seed": "//Alice",
    "account": "5EcFZ4EkYFMYcpJWyjgDde4zG8tVvmdanXeSyNTyD42r552b",
    "class_id": 1,
    "asset_id": 1,
    "metadata": {
        "userdata": "Type 1"
    }
}
```

#### Expected Output:

```
{
    "class_id": 1,
    "asset_id": 1,
    "who": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
}
```

* class\_id: the class identifier.&#x20;
* asset\_id: the asset identifier.&#x20;
* who: the account address of the asset owner.&#x20;

## Info

#### Description:

This function returns information about an asset.

#### Previous Steps:

1. [Create an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
2. [Fund an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
3. [Create a class](#create-class)
4. [Create an asset](#create)

#### Steps:

1. Call the assets/info endpoint with the following request body:

* class\_id: the class identifier.
* asset\_id: the asset identifier.

#### Example Input:

```
{
    "class_id": 1,
    "asset_id": 1
}
```

#### Expected Output:

```
{
    "info": {
        "class_id": 1,
        "asset_id": 1,
        "owner": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
        "metadata": {
            "userdata": "data"
        }
    }
}
```

* class\_id: the class identifier.
* asset\_id: the asset identifier.
* owner: the account address of the asset owner.
* metadata: additional information about the asset.

## Update Metadata

#### Description:

This function updates the asset class metadata.

#### Previous Steps:

1. [Create an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
2. [Fund an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
3. [Create a class](#create-class)
4. [Create an asset](#create)

**Steps**:

1. Call the assets/update\_metadata endpoint with the following request body:

* seed: the seed of the account that will pay for the transaction.&#x20;
* metadata: the new metadata to be set by this function.
* class\_id: the class identifier.
* asset\_id: the asset identifier.

#### Example Input:

```
{
    "seed": "//Alice",
    "metadata": {
        "userdata": "some new data"
    },
    "class_id": 1,
    "asset_id": 1
}
```

#### Expected Output:

```
{
    "class_id": 1,
    "asset_id": 1,
    "who": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
    "metadata": {
        "userdata": "some new data"
    }
}
```

* class\_id: the class identifier.
* asset\_id: the asset identifier.
* who: the account address that paid for the transaction.
* metadata: the information updated by the function.

## Mint

#### Description:

This function mints an asset by a given amount.

#### Previous Steps:

1. [Create an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
2. [Fund an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
3. [Create a class](#create-class)
4. [Create an asset](#create)

#### Steps:

1. Call the assets/mint endpoint with the following request body:

* seed: the seed of the account that will pay for the transaction.&#x20;
* class\_id: the class identifier&#x20;
* asset\_id: the asset identifier&#x20;
* to: the account address that will have ownership of the assets.&#x20;
* amount: the specific amount of assets to be minted.

#### Example Input:

```
{
    "seed": "//Alice",
    "to": "5EcFZ4EkYFMYcpJWyjgDde4zG8tVvmdanXeSyNTyD42r552b",
    "class_id": 1,
    "asset_id": 1,
    "amount": 500000
}
```

#### Expected Output:

```
{
    "to": "5EcFZ4EkYFMYcpJWyjgDde4zG8tVvmdanXeSyNTyD42r552b",
    "class_id": 1,
    "asset_id": 1,
    "amount": 500000,
    "who": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
}
```

* who: the account address that paid for the transaction.&#x20;
* class\_id: the class identifier&#x20;
* asset\_id: the asset identifier&#x20;
* to: the account address that has the ownership of the assets.&#x20;
* amount: the specific amount of assets minted.

## Burn

#### Description:

This function burns an asset by a given amount.

#### Previous Steps:

1. [Create an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
2. [Fund an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
3. [Create a class](#create-class)
4. [Create an asset](#create)

#### Steps:

1. Call the assets/burn endpoint with the following request body:

* seed: the seed of the account that will pay for the transaction.&#x20;
* class\_id: the class identifier&#x20;
* asset\_id: the asset identifier&#x20;
* from: the account address that will burn the assets.&#x20;
* amount: the specific amount of assets to be burned.

#### Example Input:

```
{
    "seed": "//Alice",
    "from": "5EcFZ4EkYFMYcpJWyjgDde4zG8tVvmdanXeSyNTyD42r552b",
    "class_id": 1,
    "asset_id": 1,
    "amount": 4000
}
```

#### Expected Output:

```
{
    "from": "5EcFZ4EkYFMYcpJWyjgDde4zG8tVvmdanXeSyNTyD42r552b",
    "class_id": 1,
    "asset_id": 1,
    "amount": 4000,
    "who": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
}
```

* who: the account address that paid for the transaction.&#x20;
* class\_id: the class identifier&#x20;
* asset\_id: the asset identifier&#x20;
* from: the account address that burned the assets.&#x20;
* amount: the specific amount of assets burned.

## Balance

#### Description:

This function checks the balance of an asset in an account.

#### Previous Steps:

1. [Create an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
2. [Fund an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
3. [Create a class](#create-class)
4. [Create an asset](#create)

#### Steps:

1. Call the assets/balance endpoint with the following request body:

* class\_id: the class identifier&#x20;
* asset\_id: the asset identifier&#x20;
* account: the account address that will be checked.

#### Example Input:

```
{
    "account": "5EcFZ4EkYFMYcpJWyjgDde4zG8tVvmdanXeSyNTyD42r552b",
    "class_id": 1,
    "asset_id": 1
}
```

#### Expected Output:

```
{
    "amount": 500000
}
```

* amount: the specific amount of assets in the given account.

## Transfer

#### Description:

This function transfers an given amounts of an asset from one account to another.

#### Previous Steps:

1. [Create an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
2. [Fund an account](https://envida-protocol.gitbook.io/envida/api-recipes/broken-reference)
3. [Create a class](#create-class)
4. [Create an asset](#create)
5. [Mint an asset](#mint)

#### Steps:

1. Call the assets/transfer\_from endpoint with the following request body:

* seed: the seed of the account that will pay for the transaction.&#x20;
* class\_id: the class identifier&#x20;
* asset\_id: the asset identifier&#x20;
* from: the account address that will send the assets.&#x20;
* to: the account address that will receive the assets&#x20;
* amount: the specific amount of assets to be sent.

#### Example Input:

```
{
    "seed": "//Alice",
    "from": "5EcFZ4EkYFMYcpJWyjgDde4zG8tVvmdanXeSyNTyD42r552b",
    "to": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
    "class_id": 1,
    "asset_id": 1,
    "amount": 50000
}
```

#### Expected Output:

```
{
    "from": "5EcFZ4EkYFMYcpJWyjgDde4zG8tVvmdanXeSyNTyD42r552b",
    "to": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
    "class_id": 1,
    "asset_id": 1,
    "amount": 50000,
    "who": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
}
```

* who: the account address that paid for the transaction.&#x20;
* class\_id: the class identifier&#x20;
* asset\_id: the asset identifier&#x20;
* from: the account address that sent the assets.&#x20;
* to: the account address that received the assets&#x20;
* amount: the specific amount of assets sent.
