I have existing ERC721 smart contract. Is there any way to migrate from my existing ERC721 to ERC1155? Or do I have to create ERC1152 separately and assign the ERC1152 token to the new account user and delete the existing ERc721 token? The reason why I want to do is that I need a batch operations to save gas fee. For example, I have several ERC721 tokens, #1,#2,#3,#4,#5 already minted, and I want it to send the account, #user1, #user2 as follows,

For #user1, token #1, #2, #3

For #user2, token #4, #5

The existing ERC721 functions can only allow me to send 5 times separately, which cost lots of GAS. Any good idea???


Just some random ideas in case it helps.

I am not sure you can transfer tokens from an ERC712 contract to an ERC1155 one. If possible, there might be better ways, but I am assuming it is not the case.

Therefore, the goal would be to find the cheapest way to create ERC1155 tokens and burn the ERC721 ones. Fortunately, you have the option to create ERC1155 tokens in batch mode (see OpenZeppelin implementation):

function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal virtual {}

In this case, you should pass an array with all tokenIDs already created from ERC721 and the amounts you consider for each, all in a single transaction. You can even override this function to create also an array for the to addresses and change the function code accordingly.

As for the ERC721, problem is that the contract is already deployed and you probably can't touch it, so you may have to burn tokens individually. Otherwise, you could have a function to burn tokens through an array of tokenIDs, in a similar way that the mintBatch function in ERC1155.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.