{"id":20974226,"url":"https://github.com/thirdweb-example/burn1155-mint721","last_synced_at":"2025-05-14T12:31:10.688Z","repository":{"id":107807758,"uuid":"535631792","full_name":"thirdweb-example/burn1155-mint721","owner":"thirdweb-example","description":"Similar to the MAYC collection, allow users who hold an NFT from your original NFT Collection to burn an ERC-1155 NFT collection to claim an NFT from your new NFT Collection!","archived":false,"fork":false,"pushed_at":"2024-04-12T00:31:06.000Z","size":176,"stargazers_count":18,"open_issues_count":0,"forks_count":25,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-02T18:22:46.821Z","etag":null,"topics":["contract-kit","erc1155","erc721","extensions"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thirdweb-example.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-12T11:18:00.000Z","updated_at":"2024-04-05T19:08:16.000Z","dependencies_parsed_at":"2024-04-12T01:44:07.631Z","dependency_job_id":null,"html_url":"https://github.com/thirdweb-example/burn1155-mint721","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thirdweb-example%2Fburn1155-mint721","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thirdweb-example%2Fburn1155-mint721/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thirdweb-example%2Fburn1155-mint721/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thirdweb-example%2Fburn1155-mint721/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thirdweb-example","download_url":"https://codeload.github.com/thirdweb-example/burn1155-mint721/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254142248,"owners_count":22021489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["contract-kit","erc1155","erc721","extensions"],"created_at":"2024-11-19T04:27:18.323Z","updated_at":"2025-05-14T12:31:09.979Z","avatar_url":"https://github.com/thirdweb-example.png","language":"CSS","readme":"\u003e [!Important]  \n\u003e This repository is referencing the `mumbai` chain.\n\u003e \n\u003e `Mumbai` [is deprecated since 08/04/2024](https://blog.thirdweb.com/deprecation-of-mumbai-testnet/), meaning the code in this repository will no longer work out of the box.\n\u003e\n\u003e You can still use this repository, however you will have to switch any references to `mumbai` to another chain.\n\n# Burn an ERC1155 to Mint an ERC721 NFT\n\nSimilar to the [Mutant Ape Yacht Club](https://opensea.io/collection/mutant-ape-yacht-club) collection, this template shows you how to:\n\n1. Build a simple ERC721A Drop Contract - Mimicking the original [BAYC Collection](https://opensea.io/collection/boredapeyachtclub)\n2. Build an ERC1155 Contract - Mimicking the [Serum NFT Collection](https://opensea.io/collection/bored-ape-chemistry-club)\n3. Create an ERC721 Drop with restrictions on who can claim, based on their ownership of the two above collections.\n\nIf you want to build a burn an erc721 token to get another erc721 token, refer to the [burn721 branch](https://github.com/thirdweb-example/burn1155-mint721/tree/burn721).\n\n## Using This Template\n\n```\nnpx thirdweb create --template burn1155-mint721\n```\n\n## Released Contracts\n\n- BAYClone: https://thirdweb.com/0xb371d1C5629C70ACd726B20a045D197c256E1054/BAYClone\n- SerumClone: https://thirdweb.com/0xb371d1C5629C70ACd726B20a045D197c256E1054/SerumClone\n- MAYClone: https://thirdweb.com/0xb371d1C5629C70ACd726B20a045D197c256E1054/MAYClone\n\n## Risks\n\nYuga Labs, the creator of the BAYC collection created a **snapshot** of NFT owner addresses and used this as an allow-list for the MAYC drop.\n\nThis prevented users from \"renting\" or temporarily gaining access to a BAYC NFT in combination with a serum and claiming the MAYC NFT.\n\nThis template does not implement a similar method of preventing this behaviour.\n\n## Guide\n\nBelow, we'll outline the key aspects of the code.\n\n### Checking Balance Before Claiming\n\nBefore the `claim` function is run in the MAYC contract, the `verifyClaim` function logic must be true.\n\nHere is where we ensure the claimer has sufficient balance of both the serum and the BAYC collection NFTs.\n\n```solidity\n    function verifyClaim(address _claimer, uint256 _quantity)\n        public\n        view\n        virtual\n        override\n    {\n        // 1. Override the claim function to ensure a few things:\n        // - They own an NFT from the BAYClone contract\n        require(bayc.balanceOf(_claimer) \u003e= _quantity, \"You don't own enough BAYC NFTs\");\n        // - They own an NFT from the SerumClone contract\n        require(serum.balanceOf(_claimer, 0) \u003e= _quantity, \"You don't own enough Serum NFTs\");\n    }\n```\n\n### Burn To Claim\n\nBefore claiming from the MAYC contract, the `_beforeTokenTransfers` function is run.\n\nIn this function, we enforce the user burns a serum\n\n```solidity\n    function claim(address _receiver, uint256 _quantity) public payable virtual override {\n        // Use the rest of the inherited claim function logic\n        super.claim(_receiver, _quantity);\n\n        // Add our custom logic to burn the serum NFTs from the caller\n        serum.burn(\n            _receiver,\n            0,\n            _quantity\n        );\n    }\n```\n\n### Providing Contract Approval to Burn\n\nFor the contract to be able to `burn` a wallet's NFTs, it needs explicit approval.\n\nWe achieve this in the application side when the user tries to claim a MAYC from the contract, by calling `setApprovalForAll`:\n\n```jsx\n  async function mintMutantNft() {\n    // Check the approval of the mayc contract to burn the user's serum tokens\n    const hasApproval = await serumContract?.call(\n      \"isApprovedForAll\",\n      address,\n      maycContract?.getAddress()\n    );\n\n    if (!hasApproval) {\n      // Set approval\n      const tx = await serumContract?.call(\n        \"setApprovalForAll\",\n        maycContract?.getAddress(),\n        true\n      );\n    }\n\n    const claimTx = await maycContract?.call(\"claim\", address!, 1);\n  }\n```\n\n## Join our Discord!\n\nFor any questions, suggestions, join our discord at [https://discord.gg/thirdweb](https://discord.gg/thirdweb).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthirdweb-example%2Fburn1155-mint721","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthirdweb-example%2Fburn1155-mint721","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthirdweb-example%2Fburn1155-mint721/lists"}