> For the complete documentation index, see [llms.txt](https://docs.megayours.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.megayours.com/yours-protocol/modules/erc1155.md).

# ERC1155

ERC1155 is an **optional** module that can be included in your dapp if you need to conform to the ERC1155 standard.

### Installation

```yaml
libs:
  ...
  yours:
    registry: https://github.com/megayours/yours-protocol.git
    path: src/lib/yours
    tagOrBranch: main
    rid: x"---"
    insecure: false
  erc1155:
    registry: https://github.com/megayours/yours-protocol.git
    path: src/lib/erc1155
    tagOrBranch: main
    rid: x"---"
    insecure: false
```

It's important to note that ERC1155 is an extension of Yours Protocol and cannot be used as a standalone module.

### Usage

ERC1155 needs to be attached to the tokens that you want to implement it.

```kotlin
namespace yours {
  import lib.yours.*;
  import lib.erc1155;
}

function attach_erc1155(yours.token, description: text, image: text, animation: text) {
  yours.erc1155.attach(token);
  yours.erc1155.set_descriptgion(token, description);
  yours.erc1155.set_image(token, image);
  yours.erc1155.set_animation(token, animation);
}
```

Now the metadata can be fetched according to ERC1155 standard externally by querying:

```kotlin
// erc1155 mount
query metadata(project: name, collection: name, token_id: big_integer)
query metadata_by_uid(uid: byte_array)
```
