{"id":7257,"date":"2024-02-23T11:55:59","date_gmt":"2024-02-23T11:55:59","guid":{"rendered":"https:\/\/metaschool.so\/articles\/?p=7257"},"modified":"2024-12-06T12:55:09","modified_gmt":"2024-12-06T12:55:09","slug":"how-metaschool-replaced-certificates-with-nfts-for-proof-of-completion","status":"publish","type":"post","link":"https:\/\/metaschool.so\/articles\/how-metaschool-replaced-certificates-with-nfts-for-proof-of-completion\/","title":{"rendered":"How Metaschool Replaced Certificates with NFTs for Proof of Completion"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_56_1 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/metaschool.so\/articles\/how-metaschool-replaced-certificates-with-nfts-for-proof-of-completion\/#Benefits_of_NFT-Based_Certificates\" title=\"Benefits of NFT-Based Certificates\">Benefits of NFT-Based Certificates<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/metaschool.so\/articles\/how-metaschool-replaced-certificates-with-nfts-for-proof-of-completion\/#Overcoming_Key_Challenges\" title=\"Overcoming Key Challenges\">Overcoming Key Challenges<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/metaschool.so\/articles\/how-metaschool-replaced-certificates-with-nfts-for-proof-of-completion\/#Technical_Implementation\" title=\"Technical Implementation\">Technical Implementation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/metaschool.so\/articles\/how-metaschool-replaced-certificates-with-nfts-for-proof-of-completion\/#The_Key_Aspects_Implemented\" title=\"The Key Aspects Implemented\">The Key Aspects Implemented<\/a><ul class='ez-toc-list-level-3'><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/metaschool.so\/articles\/how-metaschool-replaced-certificates-with-nfts-for-proof-of-completion\/#Non-Transferability\" title=\"Non-Transferability\">Non-Transferability<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/metaschool.so\/articles\/how-metaschool-replaced-certificates-with-nfts-for-proof-of-completion\/#Secure_Minting\" title=\"Secure Minting\">Secure Minting<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/metaschool.so\/articles\/how-metaschool-replaced-certificates-with-nfts-for-proof-of-completion\/#Metadata_Storage\" title=\"Metadata Storage\">Metadata Storage<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/metaschool.so\/articles\/how-metaschool-replaced-certificates-with-nfts-for-proof-of-completion\/#Seamless_NFT_Distribution\" title=\"Seamless NFT Distribution\">Seamless NFT Distribution<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/metaschool.so\/articles\/how-metaschool-replaced-certificates-with-nfts-for-proof-of-completion\/#Conclusion\" title=\" Conclusion\"> Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n\n<p>Generally, when you complete a course on a mainstream learning platform, you get a standard email along with a digital certificate, which is prone to getting edited, misused, and even copied.<\/p>\n\n\n\n<p>We, at Metaschool engineering, transformed this approach. The outcome? When you complete Metaschool courses, you are rewarded with blockchain-verified NFT certificates, offering a secure and unique token of your success.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"benefits-of-nft-based-certificates\"><span class=\"ez-toc-section\" id=\"Benefits_of_NFT-Based_Certificates\"><\/span>Benefits of NFT-Based Certificates<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>These digital assets not only signify completion just like traditional certificates; they also bring with them sundry Web3 benefits such as:<\/p>\n\n\n\n<p id=\"immutable-proof\"><strong>Immutable Proof:<\/strong> NFT ownership can&#8217;t be faked or tampered with, giving lasting validation of your skills.<\/p>\n\n\n\n<p id=\"share-ability-display-ability\"><strong>Share-ability and Display-ability:<\/strong> You can show off your NFT certificates in your crypto wallets and on sites like OpenSea.<\/p>\n\n\n\n<p id=\"true-ownership\"><strong>True Ownership:<\/strong> Certificates no longer sit unseen in a drawer. You fully own your achievements on the blockchain.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"overcoming-key-challenges\"><span class=\"ez-toc-section\" id=\"Overcoming_Key_Challenges\"><\/span><strong>Overcoming Key <\/strong>Challenges<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>As exciting as an NFT-based certificate program sounds, it wasn&#8217;t the one without a unique set of challenges. Nevertheless, my team and I succeeded in resolving these issues via multiple iterations and by following a very specific ideation process. Here are some examples to show how we did it:<\/p>\n\n\n\n<p id=\"transferability\"><strong>Transferability:<\/strong> The issue of NFT transferability was a minor challenge. We customized the contract to mint NFTs directly to the recipient&#8217;s wallet, ensuring they remain non-transferable. This effectively preserves their authenticity.<\/p>\n\n\n\n<p id=\"gas-fees\"><strong>Gas Fees:<\/strong> This can be a big challenge when minting NFTs. Therefore, we chose to deploy our NFT-based certification program on Polygon to remove the cost barrier of gas fees, ensuring developers have equal and free access.<\/p>\n\n\n\n<p id=\"authorization\"><strong>Authorization:<\/strong> Despite decentralization, we still felt a need for centralized control over mints. Thus, our contracts restrict access to only authorized admin keys.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"technical-implementation\"><span class=\"ez-toc-section\" id=\"Technical_Implementation\"><\/span>Technical Implementation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The technical implementation of our NFT-based certification program was carried out in a very strategic manner. The team and I used Polygon blockchain to build the solution and meticulously leveraged OpenZeppelin contracts. Here is how the code looked like:<\/p>\n\n\n\n<pre class=\"wp-block-code has-nv-site-bg-background-color has-background\" style=\"font-size:16px\"><code>\/\/ SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin\/contracts\/token\/ERC721\/ERC721.sol\";\nimport \"@openzeppelin\/contracts\/token\/ERC721\/extensions\/ERC721URIStorage.sol\";\nimport \"@openzeppelin\/contracts\/access\/Ownable.sol\";\nimport \"@openzeppelin\/contracts\/utils\/Counters.sol\";\n\ncontract MyToken is ERC721, ERC721URIStorage, Ownable {\n    using Counters for Counters.Counter;\n\n    Counters.Counter private _tokenIdCounter;\n    bool allowsTransfers = false;\n\n    constructor() ERC721(\"Metaschool\", \"MTA\") {}\n\n    function safeMint(address to, string memory uri) public onlyOwner {\n        uint256 tokenId = _tokenIdCounter.current();\n        _tokenIdCounter.increment();\n        _safeMint(to, tokenId);\n        _setTokenURI(tokenId, uri);\n    }\n\n    function setAllowsTransfers(bool _allowsTransfers) external onlyOwner {\n        allowsTransfers = _allowsTransfers;\n    }\n\n    \/\/ The following functions are overrides required by Solidity.\n\n    function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) {\n        super._burn(tokenId);\n    }\n\n    function tokenURI(uint256 tokenId)\n        public\n        view\n        override(ERC721, ERC721URIStorage)\n        returns (string memory)\n    {\n        return super.tokenURI(tokenId);\n    }\n\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 tokenId\n    ) internal virtual override {\n        require(\n            from == address(0) || to == address(0),\n            \"Not allowed to transfer\"\n        );\n        return super._beforeTokenTransfer(from, to, tokenId);\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-key-aspects-implemented\"><span class=\"ez-toc-section\" id=\"The_Key_Aspects_Implemented\"><\/span>The Key Aspects Implemented<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>While brainstorming the unique NFT-based certificate program, the team outlined a few key aspects that they wanted to implement such as:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"non-transferability\"><span class=\"ez-toc-section\" id=\"Non-Transferability\"><\/span>Non-Transferability<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>They overrode the <code>_beforeTokenTransfer<\/code> hook to restrict transfers. Ensuring that NFTs remain non-transferable is a major focus here so that the individual who has completed the course is the only one who owns that NFT and not transfer it to a friend. The ERC-721 standard includes an internal <strong><code>_beforeTokenTransfer<\/code><\/strong> function that is invoked before any transfer action.<\/p>\n\n\n\n<p>The engineers at Metaschool tweaked it a little and added the following condition:<\/p>\n\n\n\n<pre class=\"wp-block-code has-nv-site-bg-background-color has-background\" style=\"font-size:16px\"><code>from == address(0) || to == address(0)<\/code><\/pre>\n\n\n\n<p>It checks the from and to addresses involved in a transfer. Here, as you can see, I have restricted the action to only allow minting from address(0) and burning to address(0) operations. Any attempt to transfer an NFT from one user to another (where both from and to addresses are non-zero) triggers the function to revert the transaction, effectively making the NFTs non-transferable post-minting.<\/p>\n\n\n\n<pre class=\"wp-block-code has-nv-site-bg-background-color has-background\" style=\"font-size:16px\"><code>function _beforeTokenTransfer(\n  address from,\n  address to,\n  uint256 tokenId\n) internal virtual override {\n\n  require(\n    from == address(0) || to == address(0),\n    \"ERC721: transfer not allowed\"\n  );\n\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"secure-minting\"><span class=\"ez-toc-section\" id=\"Secure_Minting\"><\/span>Secure Minting<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The lead backend engineer used the <code>Ownable<\/code> modifier to restrict the minting ability to ensure authenticity. This also meant that the distribution of our NFTs is possible only through the owner of the contract\/s, which is none other than Metaschool\u2019s engineering team.<\/p>\n\n\n\n<pre class=\"wp-block-code has-nv-site-bg-background-color has-background\" style=\"font-size:16px\"><code>function safeMint(\/* *\/) public onlyOwner {\n  \/\/ Only contract owner can mint\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"metadata-storage\"><span class=\"ez-toc-section\" id=\"Metadata_Storage\"><\/span>Metadata Storage<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>When it comes to metadata storage, IPFS is usually recommended. However, due to time constraints, the team and I chose to go forward with Amazon S3 bucket to store all the NFT metadata. Our NFTs point to URLs like this: <a href=\"https:\/\/metaschool.s3-ap-southeast-1.amazonaws.com\/nfts\/%7Bunique-id%7D.json\" target=\"_blank\" rel=\"noopener\"><\/a><a href=\"https:\/\/metaschool.s3-ap-southeast-1.amazonaws.com\/nfts\/%7Bunique-id%7D.json\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/metaschool.s3-ap-southeast-1.amazonaws.com\/nfts\/{unique-id}.json<\/a>.<\/p>\n\n\n\n<p>Each NFT&#8217;s metadata is detailed and includes the course name, a unique image, and other key details about the recipient\u2019s achievement. Additionally, an NFT might link to metadata that looks something like this:<\/p>\n\n\n\n<pre class=\"wp-block-code has-neve-text-color-color has-nv-site-bg-background-color has-text-color has-background\" style=\"font-size:16px\"><code>{\n\t\"name\":\"Metaschool NFT\",\n\t\"description\":\"Completed the metaschool course How does Ethereum work? A deepdive\",\n\t\"image\":\"https:\/\/metaschool.s3-ap-southeast-1.amazonaws.com\/nfts\/unique-image.gif\",\n\t\"attributes\":&#91;\n\t\t\t{\"trait_type\":\"Course\",\"value\":\"How does Ethereum work? A deepdive\"},\n\t\t\t{\"trait_type\":\"Completion number\",\"value\":\"964\"}\n\t]\n} <\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"seamless-nft-distribution\"><span class=\"ez-toc-section\" id=\"Seamless_NFT_Distribution\"><\/span>Seamless NFT Distribution<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Distribution anywhere is challenging to crack. What I and my engineering team did is that they created an automated backend process to handle certificate minting and delivery:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>A cron job runs every after every one hour, identifying you who recently completed a course.<\/li><li>We check if you have connected a crypto wallet.<\/li><li>NFT metadata is prepared with course details.<\/li><li>Our contract mints an NFT and transfers it to your wallet.<\/li><\/ol>\n\n\n\n<p>This provides a smooth, gasless NFT claiming experience for all certificate earners. This architecture as a whole allows us to securely mint completion NFTs for you, our builders. The end result is a scalable system where you can claim NFT certificates as soon as you complete you course\/s.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2024\/02\/Completion-is-tracked-on-our-server-1024x512.gif\" alt=\"\" class=\"wp-image-7258\" width=\"626\" height=\"313\" srcset=\"https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2024\/02\/Completion-is-tracked-on-our-server-1024x512.gif 1024w, https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2024\/02\/Completion-is-tracked-on-our-server-300x150.gif 300w, https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2024\/02\/Completion-is-tracked-on-our-server-150x75.gif 150w, https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2024\/02\/Completion-is-tracked-on-our-server-768x384.gif 768w\" sizes=\"auto, (max-width: 626px) 100vw, 626px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span> Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This is just one example of how engineering @ Metaschool managed to provide our builders a more engaging way to own their achievements on-chain by leveraging design, coding and the key principles of engineering. You can check out our sleek NFTs on Polygon <a href=\"https:\/\/polygonscan.com\/address\/0x8b72397c6a87ed0a069afd55ab15788d8c939a03\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<p>We don\u2019t just stop here. Metaschool has a few more on-chain rewards planned for some of our existing courses.<\/p>\n\n\n\n<p>\ud83d\udc49 If what we do sounds interesting to you and can help you improve your skills, join us. Metaschool is hiring for tech roles. You can apply <a href=\"https:\/\/metaschool.so\/careers\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<p>\ud83d\udc49&nbsp;Lastly, if you have got more ideas that you want us to implement, well, feel free to drop us a quick Hello on either <a href=\"https:\/\/twitter.com\/0xmetaschool\" target=\"_blank\" rel=\"noreferrer noopener\">Twitter<\/a> or <a href=\"https:\/\/www.linkedin.com\/company\/0xmetaschool\/\" target=\"_blank\" rel=\"noreferrer noopener\">LinkedIn<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":11079,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[17,3],"tags":[51,36,328,68],"class_list":["post-7257","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blockchain","category-blog","tag-blockchain","tag-blockchain-applications","tag-nft","tag-web3-words"],"_links":{"self":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/7257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/comments?post=7257"}],"version-history":[{"count":5,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/7257\/revisions"}],"predecessor-version":[{"id":7272,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/7257\/revisions\/7272"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/media\/11079"}],"wp:attachment":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/media?parent=7257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/categories?post=7257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/tags?post=7257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}