What is "data" used for in ERC1155 mint

I understand what you are talking about here, but I have a question regarding the actual _mint call. Where you make the call:

_mint(msg.sender, GOLD, 10**18, "");

or the general case:

_mint(address account, uint256 id, uint256 amount, bytes data)

My question is, what is data for? What can you put in between the quotes in your example?

I would really appreciate any help you can give me...

Thanks!

4 Likes

Hi @prutovitz,

Welcome to the community :wave:

data is additional data with no specified format that you can use for your own purpose.

See the discussion in: ERC1155 data parameter on mint method.

1 Like

Hi Andrew,

thank-you for your quick reply. I read that thread and it is helpful but what I am trying to figure out is how it would work in practice.

What I am looking to do is to have ERC1155 tokens representing “ownership” of a video or audio file. Could the additional data refer to a URL?

Also, if I have 3 tokens defined and want to add another one on the fly as part of the same ERC1155 contract, can I do that?

Thank-you again!

Phil

1 Like

Hi @prutovitz,

I suggest having a look at projects using ERC1155 to see if they use data

Yes, though the OpenZeppelin Contracts ERC1155 implementation uses off chain metadata, which could include a URL (or IPFS hash) or a video/audio asset.

Adding data would increase the cost of minting, I would suggest trying it out to see if this works for your use case and what the additional cost is like.

The example I created has a fixed supply. You could expose a mint function (restricted using Access Control.

You could have a look at the mint on the Preset contract:

Question 1: what if we don't use Interfaces for Contracts?
Question 2: I'm building Market Place as like openSea so should i strictly follow interface of
Openzeppelin?