<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Aditi Polkam</title>
        <link>https://paragraph.com/@aditi-polkam</link>
        <description>full stack blockchain web developer🚀</description>
        <lastBuildDate>Thu, 03 Sep 2026 18:32:20 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[Everything you need to know about the ERC20 token standard]]></title>
            <link>https://paragraph.com/@aditi-polkam/everything-you-need-to-know-about-the-erc20-token-standard</link>
            <guid>2XGDynIemXE5Snn9XNrr</guid>
            <pubDate>Sun, 27 Nov 2022 13:51:05 GMT</pubDate>
            <description><![CDATA[What is a token?A token is a type of digital asset that can be used for numerous purposes like tickets to social events, payment systems, etc. They can basically represent anything and everything. Tokens may be used as proof of ownership for digital collectibles or even physical world items. They are also used to raise funds from the community.Tokens are to crypto, what shares are to the stock market💸Tokens are cryptocurrencies that are built on top of another blockchain (they are not native...]]></description>
            <content:encoded><![CDATA[<h2 id="h-what-is-a-token" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">What is a token?</h2><p>A token is a type of digital asset that can be used for numerous purposes like tickets to social events, payment systems, etc. They can basically represent anything and everything. Tokens may be used as proof of ownership for digital collectibles or even physical world items. They are also used to raise funds from the community.</p><blockquote><p>Tokens are to crypto, what shares are to the stock market💸</p></blockquote><p>Tokens are cryptocurrencies that are built on top of another blockchain (they are not native assets of the blockchain like ETH is to Ethereum and SOL is to Solana)</p><p>While every blockchain follows different rules and regulations to create and manage tokens, ERC20 is a standard used by Ethereum-based blockchains to fulfill this purpose.</p><h2 id="h-the-erc-20-standard" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">The ERC-20 standard</h2><p>ERC stands for Ethereum Request for Comment. The Ethereum-based tokens created using this standard are fungible tokens meaning that each token when replaced with another of its kind holds the same value in nature as the previous one. For example, if you replace a $1 note with another $1, it still values at $1. The same applies to cryptocurrencies like Bitcoin and Ethereum. (1 BTC will always be equal to 1 BTC) In simple words, ERC-20 tokens are interchangeable.</p><p>A token contract should have these 5 basic functionalities:</p><ol><li><p><strong>Transfer</strong> - transfer tokens from one address to another</p></li><li><p><strong>Mint</strong> - create new tokens to increase the supply</p></li><li><p><strong>Burn</strong> - remove the tokens from supply (sending them to <code>address(0)</code>)</p></li><li><p><strong>Approve</strong> - allow an address to take control of owner&apos;s tokens</p></li><li><p><strong>Transferfrom</strong> - transfer tokens from some address to another, only an address approved to do so by the owner of tokens can perform this operation</p></li></ol><p>Popularly, ERC-20 tokens are created using Openzeppelin&apos;s ERC-20 contract which can be found <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol">here</a>.</p><p>It takes only 5 lines of code to actually create ERC20 tokens but the logic behind the same is often unknown to many Solidity developers (which btw is a very big no-no).</p><p>So moving on to understanding the code of the ERC-20 contract which we inherit for our custom token contract. LFG.🚀</p><p>A contract binds together variables and functions.</p><h3 id="h-state-variables-and-mappings" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">State variables and mappings:</h3><p>The statement <code>uint public _totalSupply;</code> indicates a variable name _totalSupply with data type uint(unsigned integer) is created to maintain a count of the total tokens that are created and are currently in supply</p><p><code>mapping(address =&gt; uint) public _balances;</code> maps address to a uint number which keeps a track of the total tokens a particular address holds</p><p><code>mapping(address =&gt; mapping(address =&gt; uint)) public _allowances;</code> is a nested mapping and is used to approve a particular address to spend some amount of tokens on behalf of the sender (delegate control) here the first address is the one whose control of tokens is delegated to the second address. uint holds the number of tokens that a particular address is allowed to spend</p><p><code>string private _name;</code> stores the name of the token you will create like Aptos</p><p><code>string private _symbol;</code> stores the symbol for the token like APT</p><p>the constructor of the contract will assign these values - _name and _symbol</p><pre data-type="codeBlock" text=" constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }
"><code> <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> name_, <span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> symbol_</span>) </span>{
        _name <span class="hljs-operator">=</span> name_;
        _symbol <span class="hljs-operator">=</span> symbol_;
    }
</code></pre><h3 id="h-functions" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Functions</h3><p><strong>1.transfer</strong></p><p>Function <code>transfer</code> is a virtual function that returns a boolean and takes two arguments</p><p>a. to - the recipient to whom the tokens are to be transferred</p><p>b. amount - how many tokens are to be transferred to the recipient</p><pre data-type="codeBlock" text="function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }
"><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">transfer</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> to, <span class="hljs-keyword">uint256</span> amount</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">virtual</span></span> <span class="hljs-title"><span class="hljs-keyword">override</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">bool</span></span>) </span>{
        <span class="hljs-keyword">address</span> owner <span class="hljs-operator">=</span> _msgSender();
        _transfer(owner, to, amount);
        <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
    }
</code></pre><p><code>transfer</code> function then calls another <strong>internal</strong> function <code>_transfer</code> (with an additional argument of <code>owner</code> that stores the sender address) which executes the main logic of transferring tokens from one address to another</p><pre data-type="codeBlock" text="function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        require(from != address(0), &quot;ERC20: transfer from the zero address&quot;);
        require(to != address(0), &quot;ERC20: transfer to the zero address&quot;);

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance &gt;= amount, &quot;ERC20: transfer amount exceeds balance&quot;);
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }
"><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_transfer</span>(<span class="hljs-params">
        <span class="hljs-keyword">address</span> <span class="hljs-keyword">from</span>,
        <span class="hljs-keyword">address</span> to,
        <span class="hljs-keyword">uint256</span> amount
    </span>) <span class="hljs-title"><span class="hljs-keyword">internal</span></span> <span class="hljs-title"><span class="hljs-keyword">virtual</span></span> </span>{
        <span class="hljs-built_in">require</span>(<span class="hljs-keyword">from</span> <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), <span class="hljs-string">"ERC20: transfer from the zero address"</span>);
        <span class="hljs-built_in">require</span>(to <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), <span class="hljs-string">"ERC20: transfer to the zero address"</span>);

        _beforeTokenTransfer(<span class="hljs-keyword">from</span>, to, amount);

        <span class="hljs-keyword">uint256</span> fromBalance <span class="hljs-operator">=</span> _balances[<span class="hljs-keyword">from</span>];
        <span class="hljs-built_in">require</span>(fromBalance <span class="hljs-operator">></span><span class="hljs-operator">=</span> amount, <span class="hljs-string">"ERC20: transfer amount exceeds balance"</span>);
        <span class="hljs-keyword">unchecked</span> {
            _balances[<span class="hljs-keyword">from</span>] <span class="hljs-operator">=</span> fromBalance <span class="hljs-operator">-</span> amount;
            <span class="hljs-comment">// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by</span>
            <span class="hljs-comment">// decrementing then incrementing.</span>
            _balances[to] <span class="hljs-operator">+</span><span class="hljs-operator">=</span> amount;
        }

        <span class="hljs-keyword">emit</span> Transfer(<span class="hljs-keyword">from</span>, to, amount);

        _afterTokenTransfer(<span class="hljs-keyword">from</span>, to, amount);
    }
</code></pre><p>Here, it is checked if both addresses are valid with the <code>require</code> conditions then an optional function <code>_beforeTokenTransfer(from, to, amount);</code> can be called if there are some steps to be executed before the token transfer</p><p><code>uint256 fromBalance = _balances[from];</code> gets the sender&apos;s balance from the mapping <code>_balances</code></p><p><code>require(fromBalance &gt;= amount, &quot;ERC20: transfer amount exceeds balance&quot;);</code> is used to check if the sender has enough balance for the specified <code>amount</code> to be transferred if the condition <code>fromBalance &gt;= amount</code> is not satisfied then the transaction reverts with message &apos;ERC20: transfer amount exceeds balance&apos;</p><p>If everything goes well, we deduct the balance of sender and increase the balance of the receiver with <code>_balances[from] = fromBalance - amount;</code> &amp; <code>_balances[to] += amount;</code></p><p>Finally an event <code>emit Transfer(from, to, amount);</code> is emitted indicating successful transfer of function, and an optional function <code>_afterTokenTransfer(from, to, amount);</code> can be executed if required.</p><p><strong>2._mint</strong></p><p>This function takes an address <code>account</code> to whom the tokens will be transferred after minting and <code>amount</code> i.e. the number of tokens to be minted</p><pre data-type="codeBlock" text="function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), &quot;ERC20: mint to the zero address&quot;);

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }
"><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_mint</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> account, <span class="hljs-keyword">uint256</span> amount</span>) <span class="hljs-title"><span class="hljs-keyword">internal</span></span> <span class="hljs-title"><span class="hljs-keyword">virtual</span></span> </span>{
        <span class="hljs-built_in">require</span>(account <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), <span class="hljs-string">"ERC20: mint to the zero address"</span>);

        _beforeTokenTransfer(<span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), account, amount);

        _totalSupply <span class="hljs-operator">+</span><span class="hljs-operator">=</span> amount;
        <span class="hljs-keyword">unchecked</span> {
            <span class="hljs-comment">// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.</span>
            _balances[account] <span class="hljs-operator">+</span><span class="hljs-operator">=</span> amount;
        }
        <span class="hljs-keyword">emit</span> Transfer(<span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), account, amount);

        _afterTokenTransfer(<span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), account, amount);
    }
</code></pre><p>Here too, the address is checked to be a valid one before any other transaction is carried out.</p><p><code>_totalSupply += amount;</code> increases the total supply of tokens by <code>amount</code></p><p><code>_balances[account] += amount;</code> increases the balance of the <code>account</code> whose address was given with the <code>_mint</code> function by the number of tokens minted and finally emits a <code>Transfer</code> event</p><p><strong>3._burn</strong></p><p>This function has almost the same steps as getting the balance of the account in the <code>_mint</code> function except, instead of creating new tokens it destroys the already created ones and removes them from circulation decreasing the total supply.</p><pre data-type="codeBlock" text=" function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), &quot;ERC20: burn from the zero address&quot;);

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance &gt;= amount, &quot;ERC20: burn amount exceeds balance&quot;);
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount &lt;= accountBalance &lt;= totalSupply.
            _totalSupply -= amount;
        }

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }
"><code> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_burn</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> account, <span class="hljs-keyword">uint256</span> amount</span>) <span class="hljs-title"><span class="hljs-keyword">internal</span></span> <span class="hljs-title"><span class="hljs-keyword">virtual</span></span> </span>{
        <span class="hljs-built_in">require</span>(account <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), <span class="hljs-string">"ERC20: burn from the zero address"</span>);

        _beforeTokenTransfer(account, <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), amount);

        <span class="hljs-keyword">uint256</span> accountBalance <span class="hljs-operator">=</span> _balances[account];
        <span class="hljs-built_in">require</span>(accountBalance <span class="hljs-operator">></span><span class="hljs-operator">=</span> amount, <span class="hljs-string">"ERC20: burn amount exceeds balance"</span>);
        <span class="hljs-keyword">unchecked</span> {
            _balances[account] <span class="hljs-operator">=</span> accountBalance <span class="hljs-operator">-</span> amount;
            <span class="hljs-comment">// Overflow not possible: amount &#x3C;= accountBalance &#x3C;= totalSupply.</span>
            _totalSupply <span class="hljs-operator">-</span><span class="hljs-operator">=</span> amount;
        }

        <span class="hljs-keyword">emit</span> Transfer(account, <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), amount);

        _afterTokenTransfer(account, <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), amount);
    }
</code></pre><p><code>uint256 accountBalance = _balances[account];</code> get balance of account who is willing to destroy their tokens</p><p><code>require(accountBalance &gt;= amount, &quot;ERC20: burn amount exceeds balance&quot;);</code> checks if there is enough balance</p><p><code>_balances[account] = accountBalance - amount;</code> subtracts the balance by the <code>amount</code> of tokens to be burnt and then reduces the total supply with <code>_totalSupply -= amount;</code></p><p>Finally, a <code>Transfer</code> event is emitted. Note that the account that receives the token is <code>address(0)</code> which means they are sent to an address that cannot be operated.</p><p><strong>4.approve</strong></p><p>This function approves a particular address <code>spender</code> to spend <code>amount</code> tokens on behalf of the <code>owner</code> - sender of this message</p><pre data-type="codeBlock" text="function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }
"><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">approve</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> spender, <span class="hljs-keyword">uint256</span> amount</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">virtual</span></span> <span class="hljs-title"><span class="hljs-keyword">override</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">bool</span></span>) </span>{
        <span class="hljs-keyword">address</span> owner <span class="hljs-operator">=</span> _msgSender();
        _approve(owner, spender, amount);
        <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
    }
</code></pre><p>It calls another internal function that is <code>_approve(owner, spender, amount);</code></p><pre data-type="codeBlock" text="function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), &quot;ERC20: approve from the zero address&quot;);
        require(spender != address(0), &quot;ERC20: approve to the zero address&quot;);

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }
"><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_approve</span>(<span class="hljs-params">
        <span class="hljs-keyword">address</span> owner,
        <span class="hljs-keyword">address</span> spender,
        <span class="hljs-keyword">uint256</span> amount
    </span>) <span class="hljs-title"><span class="hljs-keyword">internal</span></span> <span class="hljs-title"><span class="hljs-keyword">virtual</span></span> </span>{
        <span class="hljs-built_in">require</span>(owner <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), <span class="hljs-string">"ERC20: approve from the zero address"</span>);
        <span class="hljs-built_in">require</span>(spender <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), <span class="hljs-string">"ERC20: approve to the zero address"</span>);

        _allowances[owner][spender] <span class="hljs-operator">=</span> amount;
        <span class="hljs-keyword">emit</span> Approval(owner, spender, amount);
    }
</code></pre><p>The changes are made in the <code>_allowances</code> mapping with <code>_allowances[owner][spender] = amount;</code></p><p>This basically means &apos;approve the <code>spender</code> to spend <code>amount</code> number of tokens on behalf of the <code>owner</code>&apos; and typically the mapping structure is somewhat like this <strong>owner ---&gt; (spender ---&gt; amount)</strong></p><p>An event is emitted with <code>emit Approval(owner, spender, amount);</code> which indicates successful approval</p><p><strong>5.transferFrom</strong></p><p>This function has 3 arguments, from - owner address (owner may not be the message&apos;s sender) to - receiver address amount - number of tokens to be transferred</p><pre data-type="codeBlock" text="function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }
"><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">transferFrom</span>(<span class="hljs-params">
        <span class="hljs-keyword">address</span> <span class="hljs-keyword">from</span>,
        <span class="hljs-keyword">address</span> to,
        <span class="hljs-keyword">uint256</span> amount
    </span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">virtual</span></span> <span class="hljs-title"><span class="hljs-keyword">override</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">bool</span></span>) </span>{
        <span class="hljs-keyword">address</span> spender <span class="hljs-operator">=</span> _msgSender();
        _spendAllowance(<span class="hljs-keyword">from</span>, spender, amount);
        _transfer(<span class="hljs-keyword">from</span>, to, amount);
        <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
    }
</code></pre><p>It eventually calls another internal function <code>_spendAllowance(from, spender, amount);</code> which has the main logic to check how much amount of tokens can the approved addresses transfer</p><p><code>_transfer(from, to, amount);</code> uses the logic as explained above to transfer tokens from one address to another</p><pre data-type="codeBlock" text="function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance &gt;= amount, &quot;ERC20: insufficient allowance&quot;);
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }
"><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_spendAllowance</span>(<span class="hljs-params">
        <span class="hljs-keyword">address</span> owner,
        <span class="hljs-keyword">address</span> spender,
        <span class="hljs-keyword">uint256</span> amount
    </span>) <span class="hljs-title"><span class="hljs-keyword">internal</span></span> <span class="hljs-title"><span class="hljs-keyword">virtual</span></span> </span>{
        <span class="hljs-keyword">uint256</span> currentAllowance <span class="hljs-operator">=</span> allowance(owner, spender);
        <span class="hljs-keyword">if</span> (currentAllowance <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-keyword">type</span>(<span class="hljs-keyword">uint256</span>).<span class="hljs-built_in">max</span>) {
            <span class="hljs-built_in">require</span>(currentAllowance <span class="hljs-operator">></span><span class="hljs-operator">=</span> amount, <span class="hljs-string">"ERC20: insufficient allowance"</span>);
            <span class="hljs-keyword">unchecked</span> {
                _approve(owner, spender, currentAllowance <span class="hljs-operator">-</span> amount);
            }
        }
    }
</code></pre><p>function <code>allowance(owner, spender)</code></p><pre data-type="codeBlock" text="function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }
"><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">allowance</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> owner, <span class="hljs-keyword">address</span> spender</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">view</span></span> <span class="hljs-title"><span class="hljs-keyword">virtual</span></span> <span class="hljs-title"><span class="hljs-keyword">override</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint256</span></span>) </span>{
        <span class="hljs-keyword">return</span> _allowances[owner][spender];
    }
</code></pre><p>calculates how many tokens owned by the <code>owner</code> are allowed to be controlled by the <code>spender</code> and assigns it to <code>currentAllowance</code></p><p>The<code>_spendAllowance</code> function then checks if <code>currentAllowance</code> that is the number of tokens approved to be controlled by the <code>spender</code> is greater than or equal to the <code>amount</code> of tokens to be transferred</p><p>Then <code>_approve(owner, spender, currentAllowance - amount)</code> is called to set the new approval limit and executes as explained above</p><p>Here new approval limit will be calculated by subtracting the tokens that will be transferred now(<code>amount</code>) from the total number of tokens allowed(<code>currentAllowance</code>)</p><p>After the <code>_spendAllowance</code> function in the <code>transferFrom</code> function is rightfully executed a call to <code>_transfer(from, to, amount);</code> is made which executes the transfer of tokens from one address to another.</p><h4 id="h-additions" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Additions</h4><p>The functions <code>increaseAllowance</code> and <code>decreaseAllowance</code> increase or decrease the number of tokens that can be controlled by the spender on behalf of the owner.</p><h3 id="h-finally-let-us-write-a-contract-to-deploy-our-own-token-on-the-blockchain" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Finally, let us write a contract to deploy our own token on the blockchain</h3><pre data-type="codeBlock" text="//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import &quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol&quot;;

contract BlogToken is ERC20{
    constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol){
        _mint(msg.sender, 10000 * 10**18);
    }
}
"><code><span class="hljs-comment">//SPDX-License-Identifier: UNLICENSED</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.8.0;</span>
<span class="hljs-keyword">import</span> <span class="hljs-string">"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol"</span>;

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">BlogToken</span> <span class="hljs-keyword">is</span> <span class="hljs-title">ERC20</span></span>{
    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> _name, <span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> _symbol</span>) <span class="hljs-title">ERC20</span>(<span class="hljs-params">_name, _symbol</span>)</span>{
        _mint(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, <span class="hljs-number">10000</span> <span class="hljs-operator">*</span> <span class="hljs-number">10</span><span class="hljs-operator">*</span><span class="hljs-operator">*</span><span class="hljs-number">18</span>);
    }
}
</code></pre><p>Note: This is a small contract to show a demo of how our own 10000 tokens can be deployed to the blockchain using <code>_mint</code> and the contract to professionally deploy a token will have a lot more functionality like approve, transferFrom, and others.</p>]]></content:encoded>
            <author>aditi-polkam@newsletter.paragraph.com (Aditi Polkam)</author>
        </item>
    </channel>
</rss>