How to send ERC1155 out of a Contract

Hi everyone,
I’m trying to understand how to implement a smart contract using openzeppin library.
In my case I’d like to deploy a smart contract that can hold erc1155 tokens and send them out when a user interact whit it.
I found wery useful this part of the documentation (https://docs.openzeppelin.com/contracts/4.x/erc1155) where it’s written that:

In order for our contract to receive ERC1155 tokens we can inherit from the convenience contract ERC1155Holder which handles the registering for us.

After that I can read that:

Though we need to remember to implement functionality to allow tokens to be transferred out of our contract

I don’t understand how I can find a reference to this tokens in order to be able to transfer them to another contract/address whenever I want after receiving them.

For example: I want to mint an NFT using OpenSea or Rarible using my address, so I can set the fees for the future sellings. After that I want to send this NFT to my contract which can send them to other addresses when someone interact with it in my dApp. Is it possible? Is there a better solution like creating the NFT contract by my own?

Moreover I’d like to find a good documentation about that because it’s really confusing so if you have suggestion on what I can read to improve my knowledge I’ll be glad to hear from you.

1 Like

Hi @marioOnto,

You could look at: Create an ERC1155

When we transfer ERC1155 to a contract, (https://docs.openzeppelin.com/contracts/4.x/api/token/erc1155#IERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) then that contract needs to implement https://docs.openzeppelin.com/contracts/4.x/api/token/erc1155#IERC1155Receiver-onERC1155Received-address-address-uint256-uint256-bytes-

Hi @abcoathup ,
Can you also show code on how to get a erc1155 token from metamask and then transfer it to another address.