# How to add any data to metadata nft?

**URL:** <https://forum.fuel.network/t/how-to-add-any-data-to-metadata-nft/2939>\
**Category:** Sway\
**Created:** [July 27, 2023, 2:07pm UTC](https://forum.fuel.network/t/how-to-add-any-data-to-metadata-nft/2939 "2023-07-27T14:07:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulZhemanov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/paulzhemanov/32/2401_2.png) [@PaulZhemanov](https://forum.fuel.network/u/PaulZhemanov)\
**Post date:** [July 27, 2023, 2:07pm UTC](https://forum.fuel.network/t/how-to-add-any-data-to-metadata-nft/2939/1 "2023-07-27T14:07:45Z")

</div>

Hi all, I am writing a contract for a Sway hackathon, can you tell me how to add any data to metadata nft. I found the metadata in the rep [https://github.com/FuelLabs/sway-libs/blob/master/libs/nft/src/extensions/token\_metadata/token\_metadata\_structures.sw](https://github.com/FuelLabs/sway-libs/blob/master/libs/nft/src/extensions/token_metadata/token_metadata_structures.sw)  
, but the documentation there is not enough for me.

This is roughly how I see using this in my contract, but I don’t understand how to do the set\_metadata and get\_metadata functions

```auto
struct MyMetadata{
  num: u64
}
...
mint(1, buyer);
set_metadata(MyMetadata{num: 1})

...
let metadata = get_metadata(nft_id);
assert(metadata.num == 1);

```

---

<div class="post-metadata">

**Author:** ![calldelegation](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/calldelegation/32/1484_2.png) [@calldelegation](https://forum.fuel.network/u/calldelegation)\
**Post date:** [July 27, 2023, 8:00pm UTC](https://forum.fuel.network/t/how-to-add-any-data-to-metadata-nft/2939/2 "2023-07-27T20:00:21Z")

</div>

Hey @PaulZhemanov it looks almost correct you just need to add the `token_id` to the function if you are importing the sway-libs metadata function

> <https://github.com/FuelLabs/sway-libs/blob/14139407704840d45d7eba9b2fa040b1b430b3a9/libs/nft/src/extensions/token_metadata.sw#L73-%23L78>
