<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: CryptoShuriken</title>
    <description>The latest articles on DEV Community by CryptoShuriken (@cryptoshuriken).</description>
    <link>https://dev.to/cryptoshuriken</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F916751%2F3d069eab-e7b6-48a7-b330-9013d304a35b.jpg</url>
      <title>DEV Community: CryptoShuriken</title>
      <link>https://dev.to/cryptoshuriken</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cryptoshuriken"/>
    <language>en</language>
    <item>
      <title>A Gentle Introduction to ERC Standards: ERC20 vs ERC721 vs ERC1155</title>
      <dc:creator>CryptoShuriken</dc:creator>
      <pubDate>Thu, 03 Nov 2022 13:43:51 +0000</pubDate>
      <link>https://dev.to/cryptoshuriken/a-gentle-introduction-to-erc-standards-erc20-vs-erc721-vs-erc1155-4e23</link>
      <guid>https://dev.to/cryptoshuriken/a-gentle-introduction-to-erc-standards-erc20-vs-erc721-vs-erc1155-4e23</guid>
      <description>&lt;p&gt;Hi, fren! gm. ☀️&lt;/p&gt;

&lt;p&gt;In this blog post, we're going to cover some of the most common ERC token standards that are used for the creation of fungible, non-fungible, and semi-fungible tokens.&lt;/p&gt;

&lt;p&gt;So, without further ado, let's get started!&lt;/p&gt;




&lt;h2&gt;
  
  
  First of all, WTH is ERC? 🤔
&lt;/h2&gt;

&lt;p&gt;ERC stands for Ethereum Request for Comments, and it is a proposal document that developers write which is then reviewed by the Ethereum community using a process called 'Ethereum Improvement Proposal' or EIP.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is ERC-20?
&lt;/h2&gt;

&lt;p&gt;ERC-20 is the 20th proposal, which was proposed in 2015 by Fabian Vogelsteller and was integrated into the Ethereum blockchain in 2017. It is the most commonly used token standard in the Ethereum ecosystem.&lt;/p&gt;

&lt;p&gt;The tokens created using the ERC-20 standard have three properties:&lt;/p&gt;

&lt;p&gt;🔹 They are Fungible: meaning all tokens can be used interchangeably and each token holds the same value. Think of a Dollar bill 💵&lt;/p&gt;

&lt;p&gt;🔹 They are transferrable: the tokens can be sent from one address to another.&lt;/p&gt;

&lt;p&gt;🔹 They have a fixed supply.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Need for ERC-20
&lt;/h3&gt;

&lt;p&gt;So back in the day when everyone was trying to come up with their own fungible tokens, there were no set rules or guidelines for developing tokens. So, everyone had to reinvent the wheel to create their own tokens.&lt;/p&gt;

&lt;p&gt;As a result, all the tokens were different from each other. This was extremely painful for developers to work with other tokens, and for exchanges and wallets to list and handle different tokens on their platforms.&lt;/p&gt;

&lt;p&gt;The ERC-20 introduced a standard (or a set of rules) that allowed developers to create their own 'Fungible' tokens on the Ethereum blockchain. It laid out a set of guidelines that all Ethereum-based tokens must adhere to.&lt;/p&gt;

&lt;p&gt;Today, wallets like Metamask and exchanges like Binance use the ERC-20 standard to list various standardized tokens onto their platforms and handle the exchange of value between them.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Technical Aspects
&lt;/h3&gt;

&lt;p&gt;ERC-20 provides a standard interface for fungible tokens.&lt;/p&gt;

&lt;p&gt;So, what is an Interface? An interface defines rules that a program must follow.&lt;/p&gt;

&lt;p&gt;In this case, it contains a set of functions and events that a smart contract must implement. While an interface doesn't specify how the functions or events should be implemented, it specifies what functions or events should be implemented.&lt;/p&gt;

&lt;p&gt;The ERC-20 standard defines three optional and six mandatory functions that a smart contract should implement to create a fungible token.&lt;/p&gt;

&lt;p&gt;The three optional ones are:&lt;/p&gt;

&lt;p&gt;🔹 &lt;code&gt;name()&lt;/code&gt;: returns the name of the token - e.g. &lt;code&gt;ShurikenToken&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;symbol()&lt;/code&gt;: returns the symbol of the token - e.g. &lt;code&gt;CST&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;symbol&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;decimals()&lt;/code&gt;: returns the number of decimals places the token uses. More on decimals &lt;a href="https://docs.openzeppelin.com/contracts/4.x/erc20#a-note-on-decimals"&gt;here&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;decimals&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;The six mandatory functions are:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;🔹 &lt;code&gt;totalSupply()&lt;/code&gt;: determines the total supply of tokens. Once this limit is reached, the smart contract will refuse to mint new tokens.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;totalSupply&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint256&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;balanceOf()&lt;/code&gt;: takes in &lt;code&gt;_owner&lt;/code&gt; address parameter and returns the number of tokens a given address holds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;balanceOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_owner&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="nb"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;transfer()&lt;/code&gt;: transfers a certain number of tokens from the total supply to a user address.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nb"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;success&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;transferFrom()&lt;/code&gt;: allows users to transfer tokens from one address to another.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;transferFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;success&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;approve()&lt;/code&gt;: verifies whether a smart contract is allowed to allocate a certain amount of tokens to a user considering the total supply, making sure that there are no extra or missing tokens.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;approve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_spender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;success&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;allowance()&lt;/code&gt;: how much an address is allowed to spend. Essentially it checks whether a user has enough balance to make transactions to another user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;allowance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_owner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_spender&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;remaining&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Apart from these functions, the smart contract should also emit &lt;strong&gt;two events&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;🔹 &lt;code&gt;Transfer&lt;/code&gt;: this event is emitted when some amount of tokens are transferred from one wallet to another. It gives the address of both the sender and recipient as well as the number of tokens transferred.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;event&lt;/span&gt; &lt;span class="n"&gt;Transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;Approval&lt;/code&gt;: this event is emitted when the approve() function is successfully executed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;event&lt;/span&gt; &lt;span class="n"&gt;Approval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_owner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_spender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;ℹ️ If you're unfamiliar with Events in Solidity, here's a fantastic &lt;a href="https://blog.chain.link/events-and-logging-in-solidity/"&gt;blog post&lt;/a&gt; by Patrick Collins on the Chainlink blog.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;The ERC-20 token standard provides a basic structure for the creation of fungible tokens in a uniform manner and takes out the complexities that used to be introduced with the "reinventing the wheel" approach in the earlier days.&lt;/p&gt;

&lt;p&gt;Now that the significance of ERC-20 is clear, let's move on to another common token standard that powered the world of something we know as NFTs.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is ERC-721?
&lt;/h2&gt;

&lt;p&gt;While the ERC-20 token standard caters to the creation of fungible tokens, ERC-721 is the token standard for creating non-fungible tokens (NFTs). It was proposed by William Entriken, Dieter Shirley, Jacob Evans, and Nastassia Sachs from the CryptoKitties team in 2018.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;ERC-721 defines a minimum interface a smart contract must implement to allow unique tokens to be managed, owned, and traded.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Unlike the ERC-20 standard, where there is no concept of "uniqueness", all tokens that are created using the ERC-721 standard are "non-fungible" or unique, and each NFT is linked to its respective owner and possesses its metadata and a unique &lt;code&gt;tokenId&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--L_a_nanz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/size/w1000/2022/10/erc20-vs-erc721.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L_a_nanz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/size/w1000/2022/10/erc20-vs-erc721.png" alt="ERC20 vs ERC721 | Image Credit: ERC721.org" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Image Credit: &lt;a href="http://erc721.org/"&gt;ERC721.org&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The use cases for the ERC-721 can be both digital &amp;amp; physical ownership. We can own digital assets like digital art, music NFTs, digital land like Decentraland, as well as physical assets like tokenized house deeds &amp;amp; real art.&lt;/p&gt;

&lt;h3&gt;
  
  
  The ERC-721 Functions and Events
&lt;/h3&gt;

&lt;p&gt;The ERC-721 standard has the following functions that a smart contract should implement:&lt;/p&gt;

&lt;p&gt;🔹 &lt;code&gt;ownerOf()&lt;/code&gt;: takes in a &lt;code&gt;_tokenId&lt;/code&gt; and returns the address of the owner of the NFT with that particular &lt;code&gt;_tokenId&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;ownerOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_tokenId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;transferFrom()&lt;/code&gt;: transfers the ownership of an NFT from one address ( &lt;code&gt;_from&lt;/code&gt;) to another ( &lt;code&gt;_to&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;transferFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_tokenId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;payable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;safeTransferFrom()&lt;/code&gt;: transfer the ownership of an NFT from one address to another. It also checks if an address receiving the NFT is an ERC-721 receiver (i.e. whether it is capable of receiving the token or not) making sure that the tokens aren't lost permanently.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;safeTransferFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_tokenId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;payable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;approve()&lt;/code&gt;: approves another entity the permission to transfer an NFT on behalf of the owner. This allows NFT platforms like OpenSea to transfer ownership of NFTs you listed for sale when someone buys it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;approve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_approved&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_tokenId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;payable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;setApprovalForAll()&lt;/code&gt;: enables or disables approval for a third party to manage all NFTs of a caller (i.e. &lt;code&gt;msg.sender&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;setApprovalForAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_operator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;_approved&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;getApproved()&lt;/code&gt;: takes in a &lt;code&gt;_tokenID&lt;/code&gt; and gets the approved address for a single NFT with that particular ID.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getApproved&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_tokenId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;isApprovedForAll()&lt;/code&gt;: queries if an address is an authorized operator for another address and returns &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; given the approval status of the operator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;isApprovedForAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_owner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_operator&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;ERC-20 compatible functions:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;🔹 &lt;code&gt;name()&lt;/code&gt; and &lt;code&gt;symbol()&lt;/code&gt;: used to define the name &amp;amp; symbol of a token. These optional functions help in providing compatibility with the ERC-20 standard and make it easier for existing wallets to display information about the token.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;_name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;symbol&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;_symbol&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;totalSupply()&lt;/code&gt;: determines the total supply of tokens. In the case of ERC-721, the total supply doesn't necessarily have to be a constant.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;totalSupply&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint256&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;balanceOf()&lt;/code&gt;: returns the count of all the NFTs a given address owns.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;balanceOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_owner&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint256&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Apart from these functions, the smart contract should also emit the following &lt;strong&gt;events&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;🔹 &lt;code&gt;Transfer&lt;/code&gt;: this event is emitted when the ownership of an NFT is transferred, or a new NFT is created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;event&lt;/span&gt; &lt;span class="n"&gt;Transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_tokenId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;Approval&lt;/code&gt;: this event is emitted when the approved address for an NFT is changed (whenever approve() function is executed).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;event&lt;/span&gt; &lt;span class="n"&gt;Approval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_owner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_approved&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_tokenId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;ApprovalForAll&lt;/code&gt;: this event is emitted when an operator is enabled or disabled for an owner. This operator can manage all NFTs of an owner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;So, while the ERC-721 token standard allows us to create unique "non-fungible" tokens, it does have its shortcomings.&lt;/p&gt;

&lt;p&gt;One key issue is that since all the tokens are unique, each token has to be sent in its own individual transaction. You can't just transfer 10 NFTs in a single transaction like you would normally do with ERC-20 tokens. As a result, it makes the entire process costly.&lt;/p&gt;

&lt;p&gt;And what if I don't want all my tokens to be unique? 🤔&lt;/p&gt;

&lt;p&gt;Think of an FPS game. Let's say the game has different types of unique skins for different weapons: Swords, Guns, throwables, etc, and an in-game currency called NinjaCoins. Let's say a user owns 1 gun, 10 swords, and 10,000 NinjaCoins.&lt;/p&gt;

&lt;p&gt;Now, if we work with the ERC-721 standard, we have to write a different smart contract for each unique item or NFT, plus we have to write another smart contract for our NinjaCoins (that will be an ERC-20 token since it's fungible).&lt;/p&gt;

&lt;p&gt;What if there was a single token standard that could facilitate the creation of both fungible and non-fungible tokens in a single deployed smart contract?&lt;/p&gt;

&lt;p&gt;Enter ERC-1155! 😎&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MRhO36Xl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://media.tenor.com/Asl8yG2ErrEAAAAC/miley-cyrus-hannah-montana.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MRhO36Xl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://media.tenor.com/Asl8yG2ErrEAAAAC/miley-cyrus-hannah-montana.gif" alt="Best of Both Worlds" width="498" height="262"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What is ERC-1155?
&lt;/h2&gt;

&lt;p&gt;The ERC-1155 token standard was introduced by Witek Radomski &amp;amp; the Enjin team in 2018.&lt;/p&gt;

&lt;p&gt;The ERC-1155 token standard combines the abilities of both ERC-20 and ERC-721 and tackles their shortcomings by providing a standard interface for smart contracts to manage multiple token types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some key features&lt;/strong&gt; of the ERC-1155 token standard are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🛠 Ability to create fungible, non-fungible, and semi-fungible tokens with a single smart contract.&lt;/li&gt;
&lt;li&gt;🔀 Ability to do batch transfers: sending multiple tokens in a single-transactions.&lt;/li&gt;
&lt;li&gt;⛽️ Gas efficient.&lt;/li&gt;
&lt;li&gt;📦 Requires less storage space.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;One key difference&lt;/strong&gt; between the ERC-20, ERC-721, and ERC-1155 is:&lt;/p&gt;

&lt;p&gt;🔹 The ERC-20 maps different addresses to the number of tokens they hold,&lt;/p&gt;

&lt;p&gt;🔹 The ERC-721 maps unique token IDs to owners, and&lt;/p&gt;

&lt;p&gt;🔹 The ERC-1155 has a nested mapping of IDs to owners to amount of tokens they own.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PsabLTip--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/size/w1000/2022/10/erc20-erc721-erc1155.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PsabLTip--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/size/w1000/2022/10/erc20-erc721-erc1155.png" alt="ERC20 vs ERC721 vs ERC1155" width="880" height="297"&gt;&lt;/a&gt;&lt;br&gt;
Image Credit: &lt;a href="https://opensea.io/blog/guides/non-fungible-tokens/#ERC721"&gt;OpenSea blog&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  The ERC-1155 Functions and Events
&lt;/h3&gt;

&lt;p&gt;The ERC-1155 token standard has the following functions that a smart contract should implement:&lt;/p&gt;

&lt;p&gt;🔹 &lt;code&gt;safeTransferFrom()&lt;/code&gt;: transfers _value amount of an _id from one address ( &lt;code&gt;_from&lt;/code&gt;) to another ( &lt;code&gt;_to&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;safeTransferFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt; &lt;span class="k"&gt;calldata&lt;/span&gt; &lt;span class="n"&gt;_data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;safeBatchTransferFrom()&lt;/code&gt;: allows the batch transfer of tokens. This function works pretty similarly to the &lt;code&gt;transferFrom()&lt;/code&gt; function in the ERC-20 standard. The only difference being we pass the &lt;code&gt;_values&lt;/code&gt; and &lt;code&gt;_ids&lt;/code&gt; as an array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ERC-20
&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;transferFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// ERC-1155
&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;safeBatchTransferFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;uint256&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="k"&gt;calldata&lt;/span&gt; &lt;span class="n"&gt;_ids&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;uint256&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="k"&gt;calldata&lt;/span&gt; &lt;span class="n"&gt;_values&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;bytes&lt;/span&gt; &lt;span class="k"&gt;calldata&lt;/span&gt; &lt;span class="n"&gt;_data&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, let's say we want to transfer 10 swords, 5 guns, and 100 NinjaCoins to an address. Let's say the IDs for swords, guns, and NinjaCoins are 2, 3, and 4 respectively.&lt;/p&gt;

&lt;p&gt;So, &lt;code&gt;_ids&lt;/code&gt; = [2, 3, 4] and &lt;code&gt;_values&lt;/code&gt; = [10, 5, 100]&lt;/p&gt;

&lt;p&gt;So, the resulting transfer with the &lt;code&gt;safeBatchTransferFrom()&lt;/code&gt; function would be:&lt;/p&gt;

&lt;p&gt;Transfer 10 tokens with id 2 from &lt;code&gt;_from&lt;/code&gt; to &lt;code&gt;_to&lt;/code&gt;.&lt;br&gt;
Transfer 5 tokens with id 3 from &lt;code&gt;_from&lt;/code&gt; to &lt;code&gt;_to&lt;/code&gt;.&lt;br&gt;
Transfer 100 tokens with id 4 from &lt;code&gt;_from&lt;/code&gt; to &lt;code&gt;_to&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;🔹 &lt;code&gt;balanceOf()&lt;/code&gt;: takes in an &lt;code&gt;_owner&lt;/code&gt; and &lt;code&gt;_id&lt;/code&gt; and gets the balance of an account's tokens of that respective token id.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;balanceOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_owner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint256&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;balanceOfBatch()&lt;/code&gt;: takes in an array of &lt;code&gt;_owners&lt;/code&gt; addresses and &lt;code&gt;_ids&lt;/code&gt;, and gets the balance of 'each' owner/id pair.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;balanceOfBatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="k"&gt;calldata&lt;/span&gt; &lt;span class="n"&gt;_owners&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="k"&gt;calldata&lt;/span&gt; &lt;span class="n"&gt;_ids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint256&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="k"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, given &lt;code&gt;_ids&lt;/code&gt; = [2, 3, 4] and &lt;code&gt;_owners&lt;/code&gt; = [0xd1dc..., 0x7c2d..., 0x1bdc...], the return value will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="n"&gt;balanceOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0xd1dc&lt;/span&gt;&lt;span class="p"&gt;...),&lt;/span&gt;
    &lt;span class="n"&gt;balanceOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x7c2d&lt;/span&gt;&lt;span class="p"&gt;...),&lt;/span&gt;
    &lt;span class="n"&gt;balanceOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x1bdc&lt;/span&gt;&lt;span class="p"&gt;...)&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;setApprovalForAll()&lt;/code&gt;: enables or disables approval for a third party ("operator") to manage all of the caller's tokens.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;setApprovalForAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_operator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;_approved&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It returns &lt;code&gt;true&lt;/code&gt; if the operator is approved, else &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;em&gt;The approvals in ERC-1155 are slightly different than ERC-20. Instead of approving specific amounts, you set an operator to approved or not approved via &lt;code&gt;setApprovalForAll()&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;🔹 &lt;code&gt;isApprovedForAll()&lt;/code&gt;: queries the current approval status of an operator for a given owner and returns &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; given the approval status of the operator. Similar to the &lt;code&gt;isApprovedForAll()&lt;/code&gt; function in the ERC-721 standard.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;isApprovedForAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_owner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;_operator&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;external&lt;/span&gt; &lt;span class="k"&gt;view&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apart from these functions, the smart contract should also emit the following &lt;strong&gt;events&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;🔹 &lt;code&gt;TransferSingle&lt;/code&gt; &amp;amp; &lt;code&gt;TransferBatch&lt;/code&gt;: either of these events must be emitted when tokens are transferred (i.e. when &lt;code&gt;safeTransferFrom()&lt;/code&gt; or &lt;code&gt;safeBatchTransferFrom()&lt;/code&gt; functions are executed).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;event&lt;/span&gt; &lt;span class="n"&gt;TransferSingle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_operator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="n"&gt;_value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;event&lt;/span&gt; &lt;span class="n"&gt;TransferBatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_operator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;_ids&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;_values&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;ApprovalForAll&lt;/code&gt;: this event is emitted when approval for a second party or operator address to manage all tokens for an owner address is enabled or disabled (i.e. when &lt;code&gt;setApprovalForAll()&lt;/code&gt; function is executed).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;event&lt;/span&gt; &lt;span class="n"&gt;ApprovalForAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_owner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_operator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;_approved&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔹 &lt;code&gt;URI&lt;/code&gt;: must be emitted when the URI for a token ID is updated.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;&lt;span class="k"&gt;event&lt;/span&gt; &lt;span class="n"&gt;URI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;_value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;uint256&lt;/span&gt; &lt;span class="k"&gt;indexed&lt;/span&gt; &lt;span class="n"&gt;_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;That's it for now, fren!&lt;/p&gt;

&lt;p&gt;We've covered a lot about the three most common ERC token standards in this blog post.&lt;/p&gt;

&lt;p&gt;We learned how the ERC-20 standard provides a basic structure for the creation of fungible tokens in a uniform manner, and how ERC-721 tackled the shortcomings &amp;amp; inefficiencies of the ERC-20 standard by providing a standard interface for creating &amp;amp; managing non-fungible tokens.&lt;/p&gt;

&lt;p&gt;And then how the ERC-1155 standard sort of combined the abilities of both ERC-20 and ERC-721 by tackling their shortcomings such as storage redundancy and gas inefficiency, providing a "best of both worlds" experience.&lt;/p&gt;

&lt;p&gt;But it does not mean that the ERC-1155 standard does not need improvement. The ever-evolving nature of the Ethereum ecosystem demands improvements in token standards as new advancements are made.&lt;/p&gt;




&lt;h2&gt;
  
  
  Prefer a TL;DR Thread?
&lt;/h2&gt;

&lt;p&gt;I've got you covered! 🙌🏻&lt;/p&gt;

&lt;p&gt;Here's a &lt;a href="https://twitter.com/cryptoshuriken/status/1588148130817617921"&gt;TL;DR version of this blog post&lt;/a&gt;. While you're at it, please consider following me &lt;a href="https://twitter.com/cryptoshuriken"&gt;@cryptoshuriken&lt;/a&gt; for more such content.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mFte2uON--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/2022/11/erc-thread.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mFte2uON--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/2022/11/erc-thread.png" alt="Twitter Thread" width="880" height="668"&gt;&lt;/a&gt;&lt;br&gt;
Image: &lt;a href="https://twitter.com/cryptoshuriken/status/1588148130817617921"&gt;A thread on ERC Token Standards - CryptoShuriken&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Recommended Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://eips.ethereum.org/EIPS/eip-20"&gt;EIP-20 Token Standard&lt;/a&gt; - Ethereum Improvement Proposals&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://cointelegraph.com/explained/erc-20-tokens-explained"&gt;ERC-20 Tokens, Explained&lt;/a&gt; - CoinTelegraph&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://eips.ethereum.org/EIPS/eip-721"&gt;EIP-721 Token Standard&lt;/a&gt; - Ethereum Improvement Proposals&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://eips.ethereum.org/EIPS/eip-1155"&gt;EIP-1155 Token Standard&lt;/a&gt; - Ethereum Improvement Proposals&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://opensea.io/blog/guides/non-fungible-tokens/"&gt;The Non-Fungible Token Bible&lt;/a&gt; - OpenSea Blog&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ethereum.org/en/developers/docs/standards"&gt;Ethereum Developer Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.openzeppelin.com/contracts/4.x/tokens"&gt;OpenZeppelin Docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;If you enjoyed reading this article, please consider &lt;a href="https://www.cryptoshuriken.com/#/portal/"&gt;subscribing here&lt;/a&gt; so that you get a notification in your mail whenever I post new stuff. Subscribing is free, and it gives me a ton of motivation to keep going.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#WAGMI&lt;/strong&gt; ✌🏻&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;a href="https://www.cryptoshuriken.com/#/portal/"&gt;Subscribe now! 📩&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LxhVuyTS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://media.tenor.com/71o0pKp1BOgAAAAC/naruto.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LxhVuyTS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://media.tenor.com/71o0pKp1BOgAAAAC/naruto.gif" alt="Naruto" width="498" height="281"&gt;&lt;/a&gt;&lt;/p&gt;




</description>
      <category>ethereum</category>
      <category>blockchain</category>
      <category>web3</category>
      <category>nft</category>
    </item>
    <item>
      <title>Getting into Web3 with #100DaysOfWeb3</title>
      <dc:creator>CryptoShuriken</dc:creator>
      <pubDate>Sun, 11 Sep 2022 13:49:49 +0000</pubDate>
      <link>https://dev.to/cryptoshuriken/getting-into-web3-with-100daysofweb3-14fa</link>
      <guid>https://dev.to/cryptoshuriken/getting-into-web3-with-100daysofweb3-14fa</guid>
      <description>&lt;p&gt;Hey, fren. gm! ☀️&lt;/p&gt;

&lt;p&gt;Are you someone who is sitting on the edge of the Web3 rabbit hole, going through roadmap videos one after another, but just can not get started?&lt;/p&gt;

&lt;p&gt;I remember myself being in the same spot, wasting weeks picking resources &amp;amp; doing nothing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vk6-_b7I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/2022/09/Screenshot-2022-09-11-at-10.26.10-AM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vk6-_b7I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/2022/09/Screenshot-2022-09-11-at-10.26.10-AM.png" alt="Analysis Paralysis" width="852" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The never-ending loop of Analysis Paralysis | Credit: &lt;a href="https://twitter.com/singhk_uttam/status/1567812417828327424?s=20&amp;amp;t=ZG1QzPsEWs8RPELEwDtQQw"&gt;Uttam Singh&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Well, good news! You don't have to pick a perfect roadmap. You just have to take the leap of faith &amp;amp; start.&lt;/p&gt;




&lt;h3&gt;
  
  
  How to get into Web3?
&lt;/h3&gt;

&lt;p&gt;Before getting into Web3, you have to figure out two things:&lt;/p&gt;

&lt;p&gt;1️⃣ &lt;strong&gt;Your "why". Why do you want to get into Web3?&lt;/strong&gt;&lt;br&gt;
Figure out what is your intrinsic motivation behind it. Is it to make money, is it the overall Web3 vibe you're attracted to, is it about flexibility, is it about building the decentralized future, or is it all of it?&lt;/p&gt;

&lt;p&gt;For me, it's more about the vibe and following my intellectual curiosity.&lt;/p&gt;

&lt;p&gt;I remember learning about Dogecoin when Elon started tweeting about it last year, passively investing small amounts I made from my SMMA work.&lt;/p&gt;

&lt;p&gt;This year I thought if I'm gonna invest any more of my money, I might as well learn the technology behind cryptocurrencies &amp;amp; blockchain.&lt;/p&gt;

&lt;p&gt;While researching good projects, I have always loved this infectious energy of the Web3 nerds. It got me excited.&lt;/p&gt;




&lt;p&gt;2️⃣ &lt;strong&gt;Your Edge. What are you good at?&lt;/strong&gt;&lt;br&gt;
Luckily, Web3 isn't all about programming. It may seem at first, but it's much more than that.&lt;/p&gt;

&lt;p&gt;So if you're not a programmer, don't sweat. There are plenty of things you can do.&lt;/p&gt;

&lt;p&gt;One thing I've learned in the past year or so is to bet on your strengths. Do what you do best, and do it better than anyone else.&lt;/p&gt;

&lt;p&gt;You can be a content creator, technical writer, researcher, community manager, designer, or marketer and still make it into Web3.&lt;/p&gt;

&lt;p&gt;Similarly, you don't have to be a 16-year-old prodigy. The best thing about the Web3 space is how open and encouraging it is for people coming from different domains.&lt;/p&gt;

&lt;p&gt;Don't be afraid to choose the road less traveled. Web3 needs diverse talent. Pick what you're innately good at and execute.&lt;/p&gt;

&lt;p&gt;I realized I don't have to be a smart contract developer to be a part of the Web3 space. I'm really good at following my intellectual curiosity, learning new things, and simplifying them for others.&lt;/p&gt;

&lt;p&gt;I don't have to be a coding genius who develops the next ground-breaking blockchain protocol. Sure, I'd like to be, but not immediately. For now, I'm happy to learn new things and teach others through &lt;a href="https://cryptoshuriken.com/"&gt;my blog&lt;/a&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  How to start?
&lt;/h3&gt;

&lt;p&gt;From today (September 11), there are exactly 112 days remaining in 2022. And I want you to make every single one of them count.&lt;/p&gt;

&lt;p&gt;For the next 100 days, take the &lt;strong&gt;#100DaysOfWeb3&lt;/strong&gt; challenge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ready to start?&lt;/strong&gt; Let's go!&lt;/p&gt;

&lt;p&gt;For the next 100 days, here's what I want you to do:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1- Pick a resource, just one!&lt;/strong&gt; It could be freeCodeCamp's Solidity course, LearnWeb3 DAO, or Alchemy's RoadToWeb3.&lt;/p&gt;

&lt;p&gt;If you try to catch two rabbits, you'll not catch either one. So, don't pick too many resources to start with. Just pick one and start.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;✨ Here are &lt;a href="https://www.cryptoshuriken.com/5-resources-to-learn-web3/"&gt;5 cool resources&lt;/a&gt; you can choose from. ✨&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;2- Go through it inside out&lt;/strong&gt;, from start to finish.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3- Make a habit of devouring content.&lt;/strong&gt; Go through external links provided in the course, be it blog posts, youtube tutorials, or keynote presentations. Just pick a topic and consume a lot of content about it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4- Teach what you've learned - The Feynman Technique.&lt;/strong&gt; Start a blog on Medium or Hashnode, or start a newsletter. Publish articles on new topics you learn. The best way to learn anything is to teach it to others. If you can't explain it to others, you don't understand it yourself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5- Learn in public.&lt;/strong&gt; You don't need 100 followers to learn in public. You can start with 0 and build your audience as you go.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6- It's tough to learn&lt;/strong&gt;, so give it back to the community. Help &amp;amp; motivate others who are on the same journey as you.&lt;/p&gt;




&lt;h3&gt;
  
  
  Ready to start? 🛣
&lt;/h3&gt;

&lt;p&gt;It's a long journey ahead. Want to make it easier?&lt;/p&gt;

&lt;p&gt;Don't go all alone - find a partner. When you're starting, sometimes it gets lonely especially when you think you're not making enough progress.&lt;/p&gt;

&lt;p&gt;Join a community, find people who are on the same journey as you, make an accountability buddy, and be accountable for each other's progress.&lt;/p&gt;

&lt;p&gt;I'm 20 days into the challenge, but I want to start over. Starting tomorrow, I'm officially restarting my &lt;strong&gt;#100DaysOfWeb3&lt;/strong&gt; challenge from scratch.&lt;/p&gt;

&lt;p&gt;Tweet at me &lt;a href="https://twitter.com/cryptoshuriken"&gt;@cryptoshuriken&lt;/a&gt; (yeah, now!) and I'll keep you accountable for the next 100 days.&lt;/p&gt;




&lt;h3&gt;
  
  
  Recommended Resources:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=lonPffWWjLk"&gt;How to get a job in Web3&lt;/a&gt; - Superteam Podcast&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://medium.com/coinmonks/why-you-shouldnt-become-a-web3-developer-what-to-do-instead-4f5c9d8c932f"&gt;Why You Shouldn’t Become A Web3 Developer &amp;amp; What To Do Instead&lt;/a&gt; - Michael Macaulay&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Hey, fren, that's it for now! Thank you for reading till the end.&lt;/p&gt;

&lt;p&gt;Let me know why you want to work in Web3 in the comments below.&lt;/p&gt;

&lt;p&gt;Also, please consider &lt;a href="https://www.cryptoshuriken.com/#/portal/"&gt;subscribing here&lt;/a&gt; so that you get a notification in your mail whenever I post new stuff. Subscribing is free, and it gives me a ton of motivation to keep going.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#WAGMI&lt;/strong&gt; ✌🏻&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TvXYqDCZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/mCiM7CmGGI4AAAAC/naruto.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TvXYqDCZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://c.tenor.com/mCiM7CmGGI4AAAAC/naruto.gif" alt="Naruto" width="498" height="371"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;em&gt;Originally published on &lt;a href="https://www.cryptoshuriken.com/getting-into-web3-with-100daysofweb3/"&gt;my blog&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>A Gentle Introduction to Blockchain Oracles &amp; Chainlink</title>
      <dc:creator>CryptoShuriken</dc:creator>
      <pubDate>Thu, 08 Sep 2022 16:42:07 +0000</pubDate>
      <link>https://dev.to/cryptoshuriken/a-gentle-introduction-to-blockchain-oracles-chainlink-3000</link>
      <guid>https://dev.to/cryptoshuriken/a-gentle-introduction-to-blockchain-oracles-chainlink-3000</guid>
      <description>&lt;p&gt;Hey, fren! gm.&lt;/p&gt;

&lt;p&gt;Previously, in week 0, I had a gentle introduction to Solidity, the preferred programming language of the Ethereum ecosystem. In the second week, I continued with the same trajectory and learned some new concepts, such as:&lt;/p&gt;

&lt;p&gt;🔹Arrays &amp;amp; Structs&lt;br&gt;
🔹Loops and Libraries&lt;br&gt;
🔹Receive &amp;amp; Fallback&lt;br&gt;
🔹Const and Immutable&lt;/p&gt;

&lt;p&gt;I also created a simple smart contract called Fund Me and while doing so, I came to know about an interesting problem called the &lt;strong&gt;Oracle problem&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  So, what is the Oracle problem?
&lt;/h3&gt;

&lt;p&gt;As we already know, a blockchain is just a public network that stores transactions in groups of blocks. In simpler times, we had blockchains like Bitcoin with a distributed public ledger that allowed people to send value from one wallet to another in a completely decentralized way.&lt;/p&gt;

&lt;p&gt;Today, there are some advanced blockchains like Ethereum that allows us to create complex “&lt;strong&gt;Dapps&lt;/strong&gt;” with the use of smart contracts that are simply digital contracts that get executed when certain conditions are met.&lt;/p&gt;

&lt;p&gt;So, let’s say we want to write a smart contract to pay John whenever he places a bet on Manchester United and Manchester United ends up winning the match.&lt;/p&gt;

&lt;p&gt;Should be pretty simple, right? All we gotta do is get the final match score and let the smart contract do its thing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But there is a problem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;How would our smart contract know that Manchester United won the match?&lt;/p&gt;

&lt;p&gt;As it turns out, smart contracts are actually not that smart. They are simply a piece of code that lives inside the blockchain, and blockchains are deterministic systems by design with no access to real-world information on their own.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZkCRebyY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/size/w1000/2022/09/oracles-chainlink-1.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZkCRebyY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/size/w1000/2022/09/oracles-chainlink-1.webp" alt="Oracles" width="880" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since blockchains do not have access to any real-world data or events, they don’t know what’s the price of ETH is, who won the football world cup, or what’s the weather like today.&lt;/p&gt;

&lt;p&gt;As a result, our smart contracts cannot interact with “off-chain” data, which is something outside their blockchain environment.&lt;/p&gt;

&lt;p&gt;So, we cannot ask our smart contract to perform calls to external APIs to check info like match scores, they are just a piece of code that lives on the blockchain and execute what they're told to do by the code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's the Oracle problem!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With the help of Oracles, we can get access to that off-chain information, and write our smart contracts in such a way that they can rely on outside information fed by an &lt;strong&gt;Oracle&lt;/strong&gt;, and make decisions based on that information.&lt;/p&gt;

&lt;p&gt;On a high level, Oracles are external services that feed real-world, off-chain information into the blockchain so that our smart contract can get access to that information and execute its logical conditions based on that data.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;So the main job of an Oracle is to provide a secure feed of external data to the blockchain and provide a validation mechanism.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Think of them as a trusted third party that provides a reliable feed of information to the smart contracts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Back to the betting example.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's say we want to access the score of today's Manchester United game. We know there are different sources and public APIs to gather that information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, we can ask an Oracle to do the following for us:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;gather info from different trusted sources, like API-Football,&lt;/li&gt;
&lt;li&gt;compare the result of each source,&lt;/li&gt;
&lt;li&gt;through its validation mechanism, figure out the correct score,&lt;/li&gt;
&lt;li&gt;supply it to the blockchain.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;🤔 So in a nutshell, an Oracle acts as a middleman between the real world and blockchain and makes sure that the smart contracts have the correct data they need to make accurate decisions.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;But there is a problem with this model. We can't trust a single centralized Oracle with the information to feed our smart contract.&lt;/p&gt;

&lt;p&gt;What if the information provided by a single Oracle is outdated, or worse, manipulated?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y45T9O6V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/size/w1000/2022/09/centralized-oracle.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y45T9O6V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/size/w1000/2022/09/centralized-oracle.webp" alt="Centralized Oracles" width="880" height="393"&gt;&lt;/a&gt; &lt;br&gt;
Image Credit: &lt;a href="https://chain.link"&gt;Chainlink&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The effectiveness of our smart contract depends on the quality of off-chain data it's being fed by the Oracles. So, we need to make sure that these Oracles should be resistant to manipulation and provide accurate &amp;amp; updated information.&lt;/p&gt;




&lt;h3&gt;
  
  
  Decentralized Oracle Network
&lt;/h3&gt;

&lt;p&gt;To ensure data accuracy without relying on a single source of truth, a &lt;strong&gt;Decentralized Oracle Network&lt;/strong&gt; combines multiple independent oracle node operators and multiple reliable data sources to establish end-to-end decentralization.&lt;/p&gt;

&lt;p&gt;Chainlink is a modular decentralized oracle network that can be utilized to deliver accurate data and perform external computation.&lt;/p&gt;

&lt;p&gt;In the Chainlink network, each independent node retrieves data from an off-chain source and brings it on-chain which is then aggregated &amp;amp; deterministically validated by the network.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VXS9JtK7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/size/w1000/2022/09/DONs.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VXS9JtK7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/size/w1000/2022/09/DONs.webp" alt="Decentralized Oracle Network" width="880" height="402"&gt;&lt;/a&gt;&lt;br&gt;
Image Credit: &lt;a href="https://chain.link"&gt;Chainlink&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  3 key solutions Chainlink provides out of the box:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1 - Chainlink Data Feeds&lt;/strong&gt;: provide a quick &amp;amp; easy way to connect smart contracts with real-world data such as the latest asset prices, weather information, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pQ-Fna6L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/size/w1000/2022/09/data-feed.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pQ-Fna6L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cryptoshuriken.com/content/images/size/w1000/2022/09/data-feed.png" alt="Chainlink data feeds" width="880" height="494"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;2 - Chainlink Verifiable Random Functions&lt;/strong&gt;: Since blockchains are deterministic systems, they can't have randomness.&lt;/p&gt;

&lt;p&gt;So, Chainlink VRFs provide a way to get provably random numbers, enabling smart contracts to guarantee fairness &amp;amp; randomness without compromising security or usability in applications that demand randomness like lotteries, randomized NFTs, gaming, etc.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;3 - Chainlink Keepers&lt;/strong&gt;: provides decentralized event-driven execution of smart contract functions after specific times or when certain events are triggered.&lt;/p&gt;

&lt;p&gt;Chainlink Keepers will listen to different events, and once a trigger returns true, Chainlink nodes will perform whatever action we want them to perform.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;📌 For example, let’s say I want to write a smart contract to withdraw funds from a fundraiser smart contract to a wallet every time the balance of my wallet goes below 1 ETH.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;To read more about Chainlink &amp;amp; Decentralized Oracle Networks, feel free to go through &lt;a href="https://docs.chain.link/"&gt;Chainlink Docs&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;So, that was a gentle introduction to Blockchain Oracles. There are still plenty of things to wrap your head around about Oracles though.&lt;/p&gt;

&lt;p&gt;That's it for now, fren!&lt;/p&gt;

&lt;p&gt;Thanks for reading till the end. If you found this post helpful or if I made a mistake somewhere, please let me know by commenting below. I'm a newbie so all the corrections are greatly appreciated.&lt;/p&gt;

&lt;p&gt;Also, please consider &lt;a href="https://www.cryptoshuriken.com/#/portal/"&gt;subscribing here&lt;/a&gt; so that you get a notification in your mail whenever I post new stuff. &lt;strong&gt;Subscribing is free&lt;/strong&gt;, and it gives me a ton of motivation to keep going.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#WAGMI&lt;/strong&gt; ✌🏻&lt;/p&gt;




&lt;p&gt;Originally published on &lt;a href="https://www.cryptoshuriken.com/blockchain-oracles-and-chainlink/"&gt;my blog&lt;/a&gt;&lt;/p&gt;




</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>solidity</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
