<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Mode Cooperators blog]]></title><description><![CDATA[This is a blog gathers all the cooperators and community contributions in one place. We will share articles about Mode, the SFS (Sequencer Fee Sharing), Layer2']]></description><link>https://mode.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1704840824740/bUvZ6TZAD.png</url><title>Mode Cooperators blog</title><link>https://mode.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 09:17:48 GMT</lastBuildDate><atom:link href="https://mode.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Introducing Molend: the Pioneering Lending Protocol on Mode Network]]></title><description><![CDATA[Molend, a lending protocol, launches on the Ethereum Layer 2 blockchain Mode Network. Users can now engage in collateralized lending and borrowing.]]></description><link>https://mode.hashnode.dev/introducing-molend-the-pioneering-lending-protocol-on-mode-network</link><guid isPermaLink="true">https://mode.hashnode.dev/introducing-molend-the-pioneering-lending-protocol-on-mode-network</guid><category><![CDATA[defi]]></category><category><![CDATA[Ethereum]]></category><category><![CDATA[Mode Network]]></category><category><![CDATA[lending solutions]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[Cryptocurrency]]></category><category><![CDATA[Web3]]></category><category><![CDATA[mode]]></category><dc:creator><![CDATA[Molend Protocol]]></dc:creator><pubDate>Tue, 19 Mar 2024 16:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1711020393022/d89e7223-2e01-45f7-be79-978dac34dd20.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://molend.org/">Molend</a>, the next-generation lending protocol, launches on the Ethereum Layer 2 blockchain <a target="_blank" href="https://www.mode.network/">Mode</a>. Users can now engage in collateralized lending and borrowing using Molend. Mode is the DeFi L2 designed for growth, incentivizing and directly rewarding developers, users, and protocols to foster the development of the Mode and superchain ecosystem.</p>
<p><strong>Traditional Lending vs Decentralized Lending</strong></p>
<p>Traditional bank lending services are known for their complex and lengthy processes, causing inconvenience for borrowers. Decentralized lending protocols, on the other hand, offer fast loan disbursements and high security, gaining increasing popularity and occupying a significant share in the DeFi space. In simple terms, users can borrow other digital assets by collateralizing their existing digital assets and engage in various profit-generating activities. This includes taking long or short positions on assets through lending, participating in DeFi farming to generate yields, or simply earning interest on deposited assets.</p>
<p><strong>Empowering Users with Molend’s Flash Loans and Loop Feature</strong></p>
<p>Molend provides two primary functions: <strong>depositing</strong> and <strong>borrowing</strong>. By placing funds into Molend, depositors can earn interest from the borrowing activities of others. <strong>Flash loan</strong>, a distinctive feature of Molend, allows borrowing &amp; repaying from the liquidity pool in a single transaction, eliminating the need for collaterals when a borrower can repay the loan atomically. Users incur only a minimal processing fee in addition to the standard gas fee, making it an efficient option for quick financial transactions. Flash Loans are particularly useful for arbitrage, enabling users to profit from price discrepancies across different protocols and liquidation opportunities.</p>
<p>Furthermore, Molend will be introducing the Loop feature in the near future to simplify the process of leveraging and borrowing assets for users. The Loop feature enables users to lend and borrow the same type of asset multiple times with a single click. More details about this feature will be revealed soon.</p>
<p><em>Note: Molend will use a point system to track users' deposits/borrowings, and allocate airdrop rewards based on the number of points.</em></p>
<p>As a highly anticipated flagship product, Molend has many advantages. Molend has high composability and can be integrated into other platforms for use. In terms of user experience, Molend provides a user-friendly data dashboard, allowing users to accurately assess profit trends and execute investment strategies. Flash Loans provide efficient investment tools for advanced users, while most of the fees generated are directly subsidized to users who have. The team behind Molend has extensive experience and a strong technical background in the cryptocurrency industry, enabling them to identify and address user pain points accurately.  </p>
<p><strong>Earn Rewardsfor Being an Early User on Molend</strong></p>
<p>MODE has a <a target="_blank" href="https://www.mode.network/about-the-airdrop">mainnet airdrop campaign</a> for early users and a point system dedicated to it. Molend will be a close partner of the campaign, meaning Molend users will earn more MODE points by using Molend.</p>
<p>Moreover, Molend is also allocating 10% of its governance token, $MLD, to early users through airdrops. As a holder of $MLD, you have governance rights over the protocol  AND  receive protocol revenue sharing. 50% of the loan interest generated across the protocol will be directed to $MLD holders,  enabling $MLD tokens with strong value capture capabilities.</p>
<p>Our point system tracks your deposits and borrowings, allowing us to allocate airdrop rewards based on the points you accumulate. The more you engage with Molend, the more rewards you can earn!</p>
<p>In the future, Molend will explore additional gameplay and features while partnering with more blockchain networks and ecosystems. Stay tuned for updates!  </p>
<p><strong>About Molend</strong></p>
<p>Molend is the next-generation lending protocol built on the Ethereum Layer 2 blockchain, Mode Network. Depositors earn passive income by providing liquidity, while borrowers access assets through over-collateralization. Powered by Mode, Molend ensures secure lending with transparent governance. Join Molend to be part of the decentralized lending revolution and unlock a world of possibilities in the Mode and Superchain ecosystem.  </p>
<p><strong>Stay Connected</strong></p>
<p><a target="_blank" href="https://twitter.com/MolendProtocol">Twitter</a> | <a target="_blank" href="https://discord.gg/eGRSCv98">Discord</a> | <a target="_blank" href="http://t.me/molend_protocol">Telegram</a> | <a target="_blank" href="https://medium.com/@molend">Medium</a></p>
]]></content:encoded></item><item><title><![CDATA[How To Setup a Multi-Signature Wallet with Safe (prev. Gnosis Safe) on Mode]]></title><description><![CDATA[Safe is a multi-sig smart contract wallet that allows you to store your assets and uses a smart contract to manage them.]]></description><link>https://mode.hashnode.dev/how-to-setup-a-multi-signature-wallet-with-safe-prev-gnosis-safe-on-mode</link><guid isPermaLink="true">https://mode.hashnode.dev/how-to-setup-a-multi-signature-wallet-with-safe-prev-gnosis-safe-on-mode</guid><category><![CDATA[Web3]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[Security]]></category><category><![CDATA[mode]]></category><category><![CDATA[layer2]]></category><category><![CDATA[optimism]]></category><dc:creator><![CDATA[The Revealer]]></dc:creator><pubDate>Thu, 15 Feb 2024 15:40:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707785166266/9e3bf1a8-4d13-4c17-b03a-6bd8078bf582.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://safe.global/">Safe</a> formerly known as Gnosis Safe is a decentralized protocol and wallet that stands at the forefront of secure asset management for Ethereum and other EVM-compatible blockchains.</p>
<p>In this guide, I will show you how to set up a Safe wallet on Mode, the modular DeFi layer 2 part of Optimism's Superchain.</p>
<h2 id="heading-what-is-gnosis-safe"><strong>What is Gnosis Safe?</strong></h2>
<p>Safe is a multi-sig smart contract wallet that allows you to store your assets.</p>
<p>Some of its core innovative functionalities include;</p>
<ul>
<li><p><strong>Multi-signature security</strong>:  Safe allows multiple owners (signers) to control a single wallet, requiring a set number of approvals for any transaction to occur. This adds a significant layer of security compared to single-signature wallets(Regular private key wallets), minimizing the risk of unauthorized access or accidental transactions.</p>
</li>
<li><p><strong>Smart contract-based</strong>:  Unlike traditional wallets, smart contracts can be modified and programmable, giving more flexibility and control. Additionally, this allows for more sophisticated features like time-locked transactions or custom execution conditions to be added to a wallet.</p>
</li>
</ul>
<h3 id="heading-why-is-multisigs-important"><strong>Why is MultiSigs Important?</strong></h3>
<p>Multisigs provide increased security for your assets, especially for businesses and organizations. Let’s take a look at a practical example to understand this better.</p>
<p>Imagine you're running a small business with two partners and need to manage a company bank account. Here's how multisigs can be beneficial:</p>
<p><strong>Scenario 1: Regular Single-Signature Account</strong></p>
<ul>
<li><p>Each partner has their login credentials and can access the funds independently.</p>
</li>
<li><p>This poses a security risk: one partner could misuse the funds without the others' knowledge.</p>
</li>
<li><p>Building trust and ensuring transparency can be challenging. Don't trust, verify.</p>
</li>
</ul>
<p><strong>Scenario 2: Multi-Signature Account with Safe</strong></p>
<ul>
<li><p>You create a Safe wallet for the business account, requiring both partners' approvals for any transaction.</p>
</li>
<li><p>Each partner holds a private key, and any transaction requires both keys to be used.</p>
</li>
<li><p>This significantly reduces the risk of unauthorized spending, as both partners must agree and sign off on transactions.</p>
</li>
<li><p>Transparency is increased as all transactions require explicit approval from both parties, building trust and reducing potential disputes.</p>
</li>
</ul>
<p>Our example shows that Safe improves transparency, offers shared control, enhances security, and reduces human error.</p>
<h2 id="heading-how-to-create-a-safe-wallet-on-mode"><strong>How to create a Safe wallet on Mode</strong></h2>
<p><strong>Step 1</strong>: Go to the <a target="_blank" href="https://staging.safe.optimism.io/welcome">Superchain Safe</a> website and connect your wallet.</p>
<p>Select Mode as your preferred Network.</p>
<p><img src="https://lh7-us.googleusercontent.com/HC96nbgo9Fs_URxxGjGohtXyYd2rGNpqqAQ2f4RR3s5M9ClEXFF96Gd_LdSlokAo8sVAmR2XiPdF92dtZUb5Xe74RPwZDQtajlMPvx7A2a6EAZDRys-TIE50vJCsJaPJBfjDxFmhV0pEoTZw_zB5rzE" alt /></p>
<p><strong>Step 2</strong>: Select your preferred wallet and authorize the action.</p>
<p><img src="https://lh7-us.googleusercontent.com/DtEDBb3oIoMuiALcZwDGWcLSA96jnDr2y1PspaNKliVHq2cTmjqbDQrA7IAp3Km5FtfbDvpPlonaTbjXltTFkol-QHUs_u91MPp3z_bsJzO9qrZ2d8UNGmSDUhv_RzVzkrs0NJVlg8BZoMJMb0IK86w" alt /></p>
<p><strong>Step 3</strong>: You won’t have Mode network set as a default in your wallet, so you would need to switch. <a target="_blank" href="https://mode.hashnode.dev/comprehensive-guide#heading-deploy-your-first-smart-contract-to-mode">Click here</a> to add Mode to your wallet if you haven’t.</p>
<p>Click the wallet area and switch to Mode.</p>
<p><img src="https://lh7-us.googleusercontent.com/VGlt4nlZ5_WW9eXonv2A-YvmzHFyWqpbQpDUly5MElauYn3AJLCjmwfe3ssxHC7gm-9UYzEbQSQ325ymlMhMspCj93_6B3VKSIQkPmgG4kHTyUySUpVjIsLVZ4W7IiFyI8_vQbW7F-HBmea1JAsisdc" alt /></p>
<p><strong>Step 4</strong>: Continue with Metamask on Mode.</p>
<p><img src="https://lh7-us.googleusercontent.com/YyMtFxUySVFcL_ICon5kDXbf4bL_6I5Ed-0aJEO4l3gZXU1tjdjhqTyRyd9SI_AZ3kheNudA-e4oGxdJMC1E_htvUMRCcrMjYI0jhWf1Nrk9UprTOjWI_Yc6zRE9j7qKqqy23g4drG-28-WnmKVpdZY" alt /></p>
<p><strong>Step 5:</strong> Create the name of your Safe.</p>
<p><img src="https://lh7-us.googleusercontent.com/cWi50VYg3F2Yy92rApSv1bHHnG_3k14xATd8v_7nFxueKO_-7xitjkJiH78OicgZ9a_TQ05A8wB_gKSA9MbZ4HXw77hszxuQzLo5qX-XajxGbGAYTD3wF0xFz0MQvFLoi8_n5V_8CTOggRM19IgNDkc" alt /></p>
<p><strong>Step 6</strong>: Add the number of owners you want for the wallet.</p>
<p>You can also set the threshold for the number of owners that must sign a transaction before it goes through.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">The amount of owners you set doesn't have to relate 1 to 1 with a person. You could also set up a Safe wallet for yourself and require 2 or more signatures to approve the tx, even if you are the owner of all the private keys.</div>
</div>

<p><img src="https://lh7-us.googleusercontent.com/RFtEr3xBeWpdArLJVAoCukl2050-ZKS4HvVyb_DRCflKap6_kIRaNMZU1Cth7MUFulcd5BoQh2bUjyBKVCI5mc5lT2lKebKdlH_v9KQ9eJKOKOCPSh1Gkk9F_YSwHBzB3C9tsaklSz_oANHbAsQHO4s" alt /></p>
<p><strong>Step 7</strong>: Review your settings, click on next, and start using the superchain safe.</p>
<p><img src="https://lh7-us.googleusercontent.com/W5WnNn1ekQuhRFumo0Oj5aCh6Fu9aaDdeV5aUcZiLPDoHO_i3L0ZXnEYmW5yizGm7N-OVUqpQxv55pocBleGuePZWNQtfPT4B_VMW2X4QwdK22ePkPDnZhSrL2e5NB9op6B7v0_Ou8RQchVTTIzL5nU" alt /></p>
<p><strong>Step 8</strong>: Wallet Created successfully!</p>
<p><img src="https://lh7-us.googleusercontent.com/K4m8-kv5zsAqJ3ocICkS22xx6nKSpDG1VCyN3iw00NDxBwkVK1_vAZ4hMz6-GcUo2pghZ21IhCKXjDnxBt9cNxmEKGIp5QJ8KNaB5SyOJh2r7hr1xtaWiiSIh6sBXOdWFWQUHlHE_R4sHrTCy6umJLY" alt /></p>
<p>Congratulations! You just created a Multisig wallet on Mode Network.Me</p>
<h3 id="heading-how-protofire-is-bringing-safe-to-the-superchain"><strong>How Protofire is Bringing Safe to the Superchain</strong></h3>
<p><a target="_blank" href="https://protofire.io/">Protofire</a> is a team of blockchain experts that helps companies and ecosystems build tools, scale their TVL(Transaction Volume), and improve their infrastructure.</p>
<p>Having been approved to build Safe for the Optimism superchain ecosystem, Protofire plans to bring Safe to the Superchain through continuous deployment and maintenance service.</p>
<p>Here's a breakdown of their plan:</p>
<p><strong>Deployment and configuration:</strong></p>
<ul>
<li><p>They will pre-deploy the <a target="_blank" href="https://github.com/safe-global/safe-singleton-factory">safe-singleton factory</a> on new networks to optimize the process.</p>
</li>
<li><p>Safe will be deployed and configured with network branding and UI integration, including two environments (Stage and Production) for both Mainnet and Testnet.</p>
</li>
<li><p>Safe will be deployed on up to 10 networks which include Mode, Zora, and PGN.</p>
</li>
</ul>
<p><strong>Support and maintenance:</strong></p>
<ul>
<li><p>Protofire will provide regular updates to Safe, monitor infrastructure, and offer support to governance and the community.</p>
</li>
<li><p>They will also develop new features with a limited scope (10 hours per network per month).</p>
</li>
</ul>
<p><a target="_blank" href="https://github.com/orgs/ethereum-optimism/projects/31/views/1?filterQuery=&amp;pane=issue&amp;itemId=46222625">Click here</a> to learn more about how Protofire plans to bring Safe to the Superchain ecosystem.</p>
<p>Note that this is still an ongoing project and can run into potential issues and bugs.</p>
<h2 id="heading-whats-next"><strong>What’s Next?</strong></h2>
<p>We’re building a community where developers and users can grow as the network grows, this is why we have several hackathons, workshops, campaign quests, and community calls to cement this goal.</p>
<p>Say hi in our <a target="_blank" href="https://discord.com/invite/modenetworkofficial">discord</a> if you have any questions or would love to be part of our community, we would love to have you.</p>
]]></content:encoded></item><item><title><![CDATA[How to Verify Smart Contracts on BlockScout with Hardhat]]></title><description><![CDATA[This guide describes step-by-step how to verify smart contracts on Blockscout using Hardhat.]]></description><link>https://mode.hashnode.dev/verify-contracts-on-blockscout-with-hardhat</link><guid isPermaLink="true">https://mode.hashnode.dev/verify-contracts-on-blockscout-with-hardhat</guid><category><![CDATA[blockscout]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[Web3]]></category><category><![CDATA[hardhat]]></category><category><![CDATA[mode]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Mon, 12 Feb 2024 11:40:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707407887589/953210a3-f9f3-44b9-8cd4-418d34a0f783.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Verifying a smart contract on Blockscout makes the contract source code publicly available and verifiable, which creates transparency and trust in the community.</p>
<p>This guide will walk you through verifying a smart contract on <a target="_blank" href="http://blockscout.com">Blockscout</a> with <a target="_blank" href="https://hardhat.com">Hardhat</a>.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before you begin the steps in this guide, please ensure you have the following:<a target="_blank" href="https://docs.celo.org/developer/verify/hardhat#prerequisites">​</a></p>
<ul>
<li><p>You should have a <a target="_blank" href="https://hardhat.org/hardhat-runner/docs/getting-started#quick-start">Hardhat project</a> initialized on your machine.</p>
</li>
<li><p>An Etherscan Account. Don't have one? go to Etherscan and <a target="_blank" href="https://etherscan.io">sign up</a> for an account.</p>
</li>
</ul>
<h2 id="heading-verifying-the-smart-contract-using-hardhat">Verifying the Smart Contract using Hardhat</h2>
<h3 id="heading-step-1-install-the-hardhat-verify-plugin">Step 1: Install the <code>Hardhat-Verify</code> Plugin</h3>
<p>The <code>hardhat-verify</code> plugin helps you verify the source code for your Solidity contracts.</p>
<p>In your project directory, install <code>hardhat-verify</code></p>
<pre><code class="lang-javascript">npm install --save-dev @nomicfoundation/hardhat-verify
</code></pre>
<p>And add the following statement to your <code>hardhat.config.js</code>:</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">require</span>(<span class="hljs-string">"@nomicfoundation/hardhat-verify"</span>);
</code></pre>
<p>Or, if you are using TypeScript, add this to your <code>hardhat.config.ts</code>:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> <span class="hljs-string">"@nomicfoundation/hardhat-verify"</span>;
</code></pre>
<h3 id="heading-step-2-configure-hardhat">Step 2: Configure Hardhat</h3>
<p>Add the following configuration to the <code>config</code> object in <code>hardhat.config.js</code>.</p>
<pre><code class="lang-javascript"> etherscan: {
    <span class="hljs-comment">// Your API key for Etherscan</span>
    <span class="hljs-comment">// Obtain one at https://etherscan.io/</span>
    <span class="hljs-attr">apiKey</span>: {
      <span class="hljs-attr">mode</span>: <span class="hljs-string">'&lt;ETHERSCAN_API_KEY&gt;'</span>,
    },
    <span class="hljs-attr">customChains</span>: [
      {
        <span class="hljs-attr">network</span>: <span class="hljs-string">'mode'</span>,
        <span class="hljs-attr">chainId</span>: <span class="hljs-number">919</span>,
        <span class="hljs-attr">urls</span>: {
          <span class="hljs-attr">apiURL</span>: <span class="hljs-string">'https://sepolia.explorer.mode.network/api\?'</span>,
          <span class="hljs-attr">browserURL</span>: <span class="hljs-string">'https://sepolia.explorer.mode.network'</span>,
        },
      },
    ],
  },
</code></pre>
<p>Replace <code>&lt;ETHERSCAN_API_KEY&gt;</code> with your API key for Etherscan. Under your Etherscan account settings, find the “API Keys” section. Generate one API key using the Free Plan.</p>
<p>This is what the <code>hardhat.config.js</code> file looks like:</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">require</span>(<span class="hljs-string">'@nomicfoundation/hardhat-toolbox'</span>);

<span class="hljs-comment">/** @type import('hardhat/config').HardhatUserConfig */</span>
<span class="hljs-built_in">module</span>.exports = {
  <span class="hljs-attr">solidity</span>: {
    <span class="hljs-attr">version</span>: <span class="hljs-string">'0.8.19'</span>,
    <span class="hljs-attr">settings</span>: {
      <span class="hljs-attr">evmVersion</span>: <span class="hljs-string">'london'</span>,
    },
  },
  <span class="hljs-attr">networks</span>: {
    <span class="hljs-string">'mode'</span>: {
      <span class="hljs-attr">url</span>: <span class="hljs-string">'https://sepolia.mode.network'</span>,
      <span class="hljs-attr">chainId</span>: <span class="hljs-number">919</span>,
      <span class="hljs-attr">accounts</span>: [<span class="hljs-string">'&lt;MY_PRIVATE_KEY&gt;'</span>],
      <span class="hljs-attr">gasPrice</span>: <span class="hljs-number">10000</span>,
    },
  },
  <span class="hljs-attr">etherscan</span>: {
    <span class="hljs-attr">apiKey</span>: {
      <span class="hljs-attr">mode</span>: <span class="hljs-string">'&lt;ETHERSCAN_API_KEY&gt;'</span>,
    },
    <span class="hljs-attr">customChains</span>: [
      {
        <span class="hljs-attr">network</span>: <span class="hljs-string">'mode'</span>,
        <span class="hljs-attr">chainId</span>: <span class="hljs-number">919</span>,
        <span class="hljs-attr">urls</span>: {
          <span class="hljs-attr">apiURL</span>: <span class="hljs-string">'https://sepolia.explorer.mode.network/api\?'</span>,
          <span class="hljs-attr">browserURL</span>: <span class="hljs-string">'https://sepolia.explorer.mode.network'</span>,
        },
      },
    ],
  },
};
</code></pre>
<h3 id="heading-step-3-deploying-and-verifying-contracts">Step 3: Deploying and Verifying Contracts</h3>
<p><strong>Deploy the Contract</strong></p>
<p>In your terminal, run the following command:</p>
<pre><code class="lang-javascript">npx hardhat run scripts/deploy.js --network mode
</code></pre>
<blockquote>
<p>Ensure you have enough funds in your account to pay for Gas. You can grab some test tokens from the <a target="_blank" href="https://faucet.modedomains.xyz/">Faucet</a> to test your contracts before deploying to the mainnet.</p>
</blockquote>
<p>Once your smart contract has been successfully deployed, we can now proceed to verify the contract using the contract address.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707405816947/fbda968f-e802-4e42-aa7b-57b96a8f6039.png" alt class="image--center mx-auto" /></p>
<p><strong>Verify the contract</strong></p>
<p>In your terminal, run the <code>verify</code> task, passing the address of the contract, the network where it's deployed, and the constructor arguments that were used to deploy it (if any):</p>
<pre><code class="lang-javascript">npx hardhat verify --network mode DEPLOYED_CONTRACT_ADDRESS <span class="hljs-string">"Constructor argument 1"</span>
</code></pre>
<p>Where <code>DEPLOYED_CONTRACT_ADDRESS</code> is the contract of your deployed smart contract. Also, replace <code>"Constructor argument 1"</code> (keep the quotes) with the arguments you passed to your smart contract when deploying.</p>
<blockquote>
<p>If you are using complex constructor arguments, reference the following <a target="_blank" href="https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify#complex-arguments">Hardhat Documentation.</a></p>
</blockquote>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Congratulations! In this guide, we’ve covered how to verify smart contracts on Blockscout with Hardhat using the <a target="_blank" href="https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify"><code>hardhat-verify</code> plugin</a> that simplifies the process. Verifying smart contracts is a crucial step in the deployment process because it allows the community to review the source code before usage, thereby promoting transparency and trust within the community.</p>
<h3 id="heading-whats-next">What's Next:</h3>
<p>Check out these other resources from the Mode C00perators:</p>
<ul>
<li><p><a target="_blank" href="https://mode.hashnode.dev/comprehensive-guide?source=koha">Mode - Comprehensive Starter Guide</a></p>
</li>
<li><p><a target="_blank" href="https://mode.hashnode.dev/get-developer-role?source=koha">How to Get the Developer Role on Mode Discord Server</a></p>
</li>
<li><p><a target="_blank" href="https://mode.hashnode.dev/how-to-register-a-smart-contract-to-mode-sfs-with-hardhat?source=koha">How to Register a Smart Contract to Mode SFS with Hardhat</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How To Setup The Mode Mainet In Metamask]]></title><description><![CDATA[This tutorial guide will walk you through the process of adding Mode Mainnet as a custom network to your MetaMask wallet. MetaMask, a popular browser…]]></description><link>https://mode.hashnode.dev/how-to-setup-the-mode-mainet-in-metamask</link><guid isPermaLink="true">https://mode.hashnode.dev/how-to-setup-the-mode-mainet-in-metamask</guid><category><![CDATA[Ethereum]]></category><dc:creator><![CDATA[Gordian Etim]]></dc:creator><pubDate>Mon, 12 Feb 2024 11:36:58 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707594378907/fa21f0a7-23a2-427c-b6f0-e443c5fd94f0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-introduction">INTRODUCTION</h3>
<p>This tutorial guide will walk you through the process of adding Mode Mainnet as a custom network to your MetaMask wallet.</p>
<p>MetaMask, a popular browser extension for managing your Ethereum-based assets, allows users to seamlessly connect to various networks, and Mode Dev Mainnet is no exception in this guide as well.</p>
<p><strong>Using Browser (Chrome Browser )</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706630392765/531b805f-6476-44e5-a93a-5aa34c2bccf8.png" alt class="image--center mx-auto" /></p>
<p><strong>Download MetaMask Extension from Chrome Web store (Web Browser)</strong></p>
<p><strong>Step 1: Open the MetaMask Browser Extension</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706630432148/ad6a5fcb-8161-4c68-894c-f326320c669b.png" alt class="image--center mx-auto" /></p>
<p><strong>Step 2: Access the Network Selection Dropdown</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706630559145/3eb12f31-066a-45a9-91a0-b011f034f12a.png" alt class="image--center mx-auto" /></p>
<p>In the MetaMask interface, locate the network selection dropdown menu. You can find this dropdown by clicking the button at the top of the MetaMask extension. It typically displays the currently selected network.</p>
<p><strong>Step 3: Add a New Network</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706630584606/b51683df-5c7e-4853-8b66-2be4ff4fc99d.png" alt class="image--center mx-auto" /></p>
<p>Once you have the network selection dropdown open, look for the "Add network" button. Click on it to initiate the process of adding a new network to your MetaMask wallet.</p>
<p><strong>Step 4: Enter Network Information</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706630621558/ce1a99dc-010a-45ea-b554-a4f1b9c5d456.png" alt class="image--center mx-auto" /></p>
<p>A dialog box titled "Add a network manually" will appear. Here, you need to input the following information:</p>
<ul>
<li><p><strong>Network Name:</strong> Mode Mainnet</p>
</li>
<li><p><strong>RPC Endpoint:</strong><a target="_blank" href="https://mainnet.mode.network/">https://mainnet.mode.network/</a></p>
</li>
<li><p><strong>Chain ID:</strong> 34443</p>
</li>
<li><p><strong>Currency Symbol:</strong> ETH</p>
</li>
<li><p><strong>Block Explorer:</strong><a target="_blank" href="https://explorer.mode.network/">https://explorer.mode.network/</a></p>
</li>
</ul>
<p>Ensure the accuracy of the provided information to avoid any connectivity issues.</p>
<p><strong>Step 5: Save the New Network</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706630718930/ff9d3dbe-281d-4236-8cb9-8703e86b401b.png" alt class="image--center mx-auto" /></p>
<p>Having entered the Mode Mainnet details, tap the "Save" button to store this network configuration in your MetaMask wallet. This step is important for establishing a seamless connection to the Mode Mainnet in the future.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706630732572/cade213f-7c25-4dc2-b4e7-e256ce22981f.png" alt class="image--center mx-auto" /></p>
<p>Watch video here:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/l3bm1MyzRPo?si=YxBdPJfVEDhyvI-f">https://youtu.be/l3bm1MyzRPo?si=YxBdPJfVEDhyvI-f</a></div>
<p> </p>
<p><strong>Congratulations.</strong></p>
<p>You have successfully added the <strong>Mode Dev Mainnet</strong> as a custom network to your MetaMask wallet.</p>
<p>You should now be able to connect to the Mode Mainnet by selecting it from the network selection dropdown menu.</p>
<p>Now you've learned how to add Mode to Metamask, you can test it out by checking out our ecosystem DApps <a target="_blank" href="https://www.mode.network/ecosystem">here</a>.</p>
]]></content:encoded></item><item><title><![CDATA[How To Register a Smart Contract to the SFS with Foundry]]></title><description><![CDATA[Foundry is an Ethereum development platform that provides tools for managing your dependencies, testing, running, and deploying your project.]]></description><link>https://mode.hashnode.dev/how-to-register-a-smart-contract-to-the-sfs-with-foundry</link><guid isPermaLink="true">https://mode.hashnode.dev/how-to-register-a-smart-contract-to-the-sfs-with-foundry</guid><category><![CDATA[Blockchain]]></category><category><![CDATA[foundry]]></category><category><![CDATA[Smart Contracts]]></category><category><![CDATA[Web3]]></category><dc:creator><![CDATA[The Revealer]]></dc:creator><pubDate>Mon, 12 Feb 2024 11:32:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706229850254/da9d6e4b-16ff-4f65-bfca-22d98aba551d.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Foundry is an Ethereum development platform that provides tools for managing your dependencies, testing, running, and deploying your project. It also allows you to interact with your project from the command line.</p>
<p>In this tutorial, you’ll learn how to register our smart contract to the Mode SFS contract with Foundry.</p>
<h3 id="heading-prerequisites"><strong>Prerequisites</strong></h3>
<p>Before you continue with this tutorial you should:</p>
<ol>
<li><p>Have <a target="_blank" href="https://book.getfoundry.sh/getting-started/installation">Foundry</a> Installed</p>
</li>
<li><p><a target="_blank" href="https://docs.mode.network/mode-testnet/bridging-to-mode-testnet">Bridge</a> Sepolia Eth with Mode Network.</p>
</li>
<li><p>Have an Ethereum wallet preferably <a target="_blank" href="https://metamask.io/">Metamask</a> Installed.</p>
</li>
<li><p>A basic understanding of Solidity.</p>
</li>
</ol>
<h2 id="heading-the-register-function-in-the-sfs-contract"><strong>The Register Function in the SFS contract</strong></h2>
<p>Mode’s SFS contract lets developers get some percentage of the transaction fees from their contracts' activities on the Mode network. For this to work, your smart contract has to be registered to Mode’s SFS contract. Once registered, you get an ERC 721 NFT (Non-Fungible Token) which allows you to claim your share of the transaction fees generated from your contract.</p>
<p>To register, your smart contract must call the SFS contract's register function. Let’s look at the register function to understand how it works.</p>
<p>Note that this is only a portion of the SFS contract, <a target="_blank" href="https://sepolia.explorer.mode.network/address/0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6?tab=contract">check here</a> to see the complete code.</p>
<pre><code class="lang-solidity"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">register</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> _recipient</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title">onlyUnregistered</span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> 
(<span class="hljs-params"><span class="hljs-keyword">uint256</span> tokenId</span>) </span>{

   <span class="hljs-keyword">address</span> smartContract <span class="hljs-operator">=</span> <span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>;

<span class="hljs-comment">// Check if the recipient address is valid; revert if it's null</span>
   <span class="hljs-keyword">if</span> (_recipient <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-keyword">revert</span> InvalidRecipient();

<span class="hljs-comment">// Generate a unique tokenId, mint an NFT to the recipient with it, and update    </span>
<span class="hljs-comment">//the tracker</span>
   tokenId <span class="hljs-operator">=</span> _tokenIdTracker.current();
   mint(recipient, tokenId);
   _tokenIdTracker.increment();
   <span class="hljs-keyword">emit</span> Register(smartContract, _recipient, tokenId);

<span class="hljs-comment">// Update the fee recipient mapping for the smart contract, associating it with </span>
<span class="hljs-comment">//the tokenId and registration details</span>
   feeRecipient[smartContract] <span class="hljs-operator">=</span> NftData({
       tokenId: tokenId,
       registered: <span class="hljs-literal">true</span>,
       balanceUpdatedBlock: <span class="hljs-built_in">block</span>.<span class="hljs-built_in">number</span>
   });

}
</code></pre>
<p>This function receives <strong><em>_recipient</em></strong> as an input and then mints an NFT to this recipient once your smart contract is registered.</p>
<p>Then, the <strong><em>msg.sender</em></strong> is picked up as the contract to register in the SFS updating the mapping with relevant information.</p>
<p>Here are a few things to note;</p>
<ul>
<li><p>The function is specified <strong><em>public</em></strong> meaning an external smart contract can call it.</p>
</li>
<li><p>The <strong><em>msg.sender</em></strong> is assumed to be a smart contract address, ensuring that a smart contract can register a fee recipient.</p>
</li>
<li><p>The function mints an ownership NFT that allows the owner to claim fees earned by the recipient smart contract.</p>
</li>
</ul>
<p>Now that we’ve understood how the register function works, let’s set up our project.</p>
<h3 id="heading-1-creating-your-project"><strong>1. Creating your Project</strong></h3>
<p>To Initialize a new project with Forge open up your terminal and run;</p>
<pre><code class="lang-bash">$ mkdir mode-project 
$ <span class="hljs-built_in">cd</span>  mode-project 
$ forge init
</code></pre>
<p>This creates a project structure, you can configure it according to your taste but for this tutorial, we would be sticking with the default structure and only make minor changes to our file.</p>
<p><img src="https://lh7-us.googleusercontent.com/9o1-V2MxybRq0_-iSUzK9PcBUbyYKKWHUydrztLcht1-tl8fe98EFkkqmqjDV8GA6r0PWP9vap1S0KYeASkp-YkPNNtnfh0NhNh5rRnAmnsgtG63hcnojR9Jli0wHXTPS4sM16r4GdPgC6KvX4DKWyc" alt /></p>
<h3 id="heading-2-writing-your-contract">2. Writing your Contract</h3>
<p>We won’t be making use of Openzepplin in this tutorial, but because you’d be making use of it frequently I’d give you the steps. Apply if you want to add it to your project.</p>
<p>Install the Openzeppelin library inside your project by running;</p>
<pre><code class="lang-bash">$ forge install openzeppelin/openzeppelin-contracts
</code></pre>
<p>This would add the openzeppelin library to the <strong><em>lib/openzeppelin-contracts</em></strong> directory and you can make use of it with a simple import.</p>
<p><strong>Note:</strong> For Forge to find this dependency you have to create a remappings.txt file at the top level of your project.</p>
<p>Add this line to the file</p>
<pre><code class="lang-bash">@openzeppelin/=lib/openzeppelin-contracts/
</code></pre>
<p>With that said, head to the src folder and replace the contract with this one. Also, don’t forget to delete the test file.</p>
<pre><code class="lang-solidity"><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.13;</span>
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Register</span> </span>{
  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">register</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> _recipient</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint256</span> tokenId</span>) </span>{}
}
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">ModeTest</span> </span>{
  <span class="hljs-keyword">uint</span> <span class="hljs-keyword">public</span> value;

  <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">uint</span> _initialValue</span>) </span>{
      value <span class="hljs-operator">=</span> _initialValue;
      Register sfsContract <span class="hljs-operator">=</span> Register  (<span class="hljs-number">0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6</span>);
      sfsContract.register(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>);
  }
  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">updateValue</span>(<span class="hljs-params"><span class="hljs-keyword">uint</span> _newValue</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
      value <span class="hljs-operator">=</span> _newValue;
  }
}
</code></pre>
<h3 id="heading-3-compiling-your-contract">3. Compiling your Contract</h3>
<p>To compile your contract simply run;</p>
<pre><code class="lang-bash">$ forge build
</code></pre>
<h3 id="heading-4-deploying-your-contract">4. Deploying your Contract</h3>
<p>To deploy your contract run;</p>
<pre><code class="lang-bash">mode-project % forge create --rpc-url https://sepolia.mode.network \ 
--constructor-args 100 \ 
--private-key &lt;Your Private Key&gt; src/Mode.sol:ModeTest
</code></pre>
<p>The constructor args was added because we have to provide arguments for our constructor.</p>
<p>Replace the private key completely with your private key, it should return something like this.</p>
<p><strong>[⠑</strong>] Compiling…</p>
<p><em>No files changed, compilation skippedDeployer: 0x08755B4d595AFA790d760CF499778f8ff610607EDeployed to: 0x1a06b0ba12Bb0568c7BDEEf1e4573Dd78C74544fTransaction hash: 0x95b9fbd23bdc9513cb089a64287b87e1642508f2fcc123b3c6a4dbe0c5cd3e1b</em></p>
<p>Congratulations! You just deployed and registered your contract with Foundry.</p>
<h2 id="heading-check-the-explorer"><strong>Check the Explorer</strong></h2>
<p>To view your transaction head to <a target="_blank" href="https://sepolia.explorer.mode.network/">Mode Testnet</a> and paste the contract address. Your contract should be assigned to the NFT tokenId. To verify if you assigned your contract correctly, you can check our <a target="_blank" href="https://docs.mode.network/build-on-mode/tutorials/sfs-sequencer-fee-sharing/sfs-check-the-registry">“Check the registry”</a> guide.</p>
<p>To import the NFT to your wallet, check our <a target="_blank" href="https://docs.mode.network/build-on-mode/tutorials/sfs-sequencer-fee-sharing/sfs-check-the-registry#adding-the-sfs-nft-to-your-wallet">Adding the SFS NFT to your wallet</a> tutorial.</p>
]]></content:encoded></item><item><title><![CDATA[Exploring the ModeNetwork Universe]]></title><description><![CDATA[Discover my fascinating journey in the world of Mode Network, from the first glimmer of curiosity to the development of my first dapp.]]></description><link>https://mode.hashnode.dev/exploring-the-modenetwork-universe</link><guid isPermaLink="true">https://mode.hashnode.dev/exploring-the-modenetwork-universe</guid><category><![CDATA[Web3]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[L2]]></category><category><![CDATA[Mode Network]]></category><category><![CDATA[dapps]]></category><dc:creator><![CDATA[Luis Fernando Ushiña]]></dc:creator><pubDate>Mon, 12 Feb 2024 10:51:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707364997700/8271f041-1414-4e1a-97e8-58fe802c2d18.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Since I first delved into the world of Mode Network blockchain, every step I've taken has been an exciting adventure filled with learning and discovery. As I progressed on my journey, I found myself increasingly fascinated by the potential and possibilities that this technology offers.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707284870566/8272f838-91ed-4f5d-985c-7428f0ec6e7a.png?auto=compress,format&amp;format=webp" alt /></p>
<p><strong>In Search of "The Mode"</strong></p>
<p>My first steps into Mode Network were exciting and full of curiosity. Initially, the multitude of resources I managed to gather, from articles to instructional videos, to understand the fundamentals of this technology and its benefits, might seem overwhelming. Each new piece of information I absorbed brought me closer to understanding how this decentralized network works and its promise of improvement through cooperation. This undoubtedly reminded me of the ubuntu philosophy "I am what I am because of what we all are."</p>
<p><img src="https://cdn.thecollector.com/wp-content/uploads/2023/12/ubuntu-philosophy-introduction.jpg?width=1400&amp;quality=70" alt="I Am Because We Are”: Introducing Ubuntu Philosophy" /></p>
<p><strong>Diving into Mode Network</strong></p>
<p>Driven by deep curiosity and a passion for learning, I decided it was time to fully immerse myself in the Mode Network ecosystem. I superficially explored the complexities that could arise from smart contracts, asset tokenization, and the inherent security of this technology. Each new concept I learned opened new doors of possibilities and encouraged me to continue on my journey of discovery.</p>
<p>One of the most valuable resources for the path I was taking was the technical documentation, although I know nobody likes it, sometimes there comes a time in life when you have to do it.</p>
<p>By the way, I leave it here 👉 <a target="_blank" href="https://docs.mode.network/introduction/introducing-mode"><strong>Technical Documentation</strong></a></p>
<p>In the midst of my exploration, I found my first inspiration in Mode's transformative potential. It was then that the idea of ​​creating an application that would allow the community to support projects in a decentralized way through small donations was born. This vision became my guide as I embarked on the development of my first dapp on the Mode Network blockchain.</p>
<p><strong>Getting to Work</strong></p>
<p>Well, with a clear vision in mind, it was time to get to work. I opened the documentation and so I started the development of my donations application on the Mode Network blockchain.</p>
<p>Every line of code I wrote was a small step towards realizing my super idea. I wrote the smart contract, a donation function here, a withdrawal function there, a small deployment with remix, SFS registration, and voila, the smart contract was complete and ready to be implemented.</p>
<p>Just for this occasion, I won't overwhelm anyone with too much code, however, I will leave the link to the contract I used for that dev who is curious 👉 <a target="_blank" href="https://sepolia.explorer.mode.network/address/0x1cdb4Aad28fbc25836F0A2185e8b3F76a5395611"><strong>Contract used</strong></a></p>
<p>It was very interesting to understand that with just an NFT (plus all the work of the Mode Team) I could have the opportunity to obtain benefits as a developer. That reward system design. Wow, the work they have done from Mode!</p>
<p>And I, for my part, was also giving it my all and there was finally my promised NFT.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707287413323/e2e61435-3a91-42c4-afe2-a706b417d35a.png?auto=compress,format&amp;format=webp" alt /></p>
<p>After this, I felt much more motivated. I continued with a small front.</p>
<p>After hard work and dedication, the time came for "The Big Launch".</p>
<p>With a heart full of excitement and nervousness, I shared my creation with the Mode Network community.</p>
<p>The first reactions were positive and I received the support and validation I had been looking for. I know it's still not the application that will change the world, but for me, it marked an important milestone on this journey, in search of "The Mode".</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706112460649/d68db8c6-7a01-481e-8955-013385ab9b60.png?auto=compress,format&amp;format=webp" alt /></p>
<p>Would you like to try it? You can do it by entering here: <a target="_blank" href="https://community-donations.vercel.app/"><strong>Generosity in action</strong></a></p>
<p><strong>What's next?</strong></p>
<p>Looking ahead, as I celebrate my achievements, I can't help but be excited about what the future holds for the world of Mode Network.</p>
<p>My journey is far from over, and I'm eager to continue exploring new opportunities and contributing to the growth of this fascinating ecosystem. Every day is a new opportunity to learn, grow, and create in Mode.</p>
<p>If anything from this journey should stay in your mind, I hope it's the excitement for knowledge and the curiosity to continue exploring and creating passionately in this world.</p>
<p>I leave you my social networks in case you want to collaborate on this or another project, or if you want to contribute with ideas, improvements, or simply want to improve your networking, feel free to contact me.</p>
<ul>
<li><p>Github: <a target="_blank" href="https://github.com/wolfcito"><strong>AKAwolfcito</strong></a></p>
</li>
<li><p>Twitter: <a target="_blank" href="https://twitter.com/AKAwolfcito"><strong>AKAwolfcito</strong></a></p>
</li>
<li><p>Discord: <a class="user-mention" href="https://hashnode.com/@akawolfcito">@akawolfcito</a></p>
</li>
</ul>
<p><a target="_blank" href="https://wolfcito.hashnode.dev/explorando-el-universo-de-modenetwork">Click here to see the original article in Spanish.</a></p>
]]></content:encoded></item><item><title><![CDATA[How to get the Developer Role on the Mode Discord Server]]></title><description><![CDATA[This article describes step-by-step how to grab the Developer Role on Mode Discord Server.]]></description><link>https://mode.hashnode.dev/get-developer-role</link><guid isPermaLink="true">https://mode.hashnode.dev/get-developer-role</guid><category><![CDATA[Web3]]></category><category><![CDATA[discord]]></category><category><![CDATA[L2]]></category><category><![CDATA[layer2]]></category><category><![CDATA[mode]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Wed, 07 Feb 2024 18:44:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707330423843/5bb96415-fdf6-4ff5-a6f9-5afd2645ab98.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you are a developer building on Mode, you have the opportunity to get access to an exclusive role in the Mode Discord server, granting access to a private chat to get support, connect, and build your network.</p>
<p>This guide offers step-by-step instructions to get access to the <code>Developer</code> role.</p>
<p>It only takes 2 minutes!</p>
<h3 id="heading-claiming-the-developer-role">Claiming the Developer Role</h3>
<p>Open Discord and navigate to the <a target="_blank" href="https://dub.sh/mode-discord">Mode Discord Server</a>.</p>
<p><img src="https://lh7-us.googleusercontent.com/n-7Jr9gc1lJ7uckhfb7ovmgORfjef0Eyi06Pniz65n--ERi8W3-vz6NZZ447xKUL1mEKE7om3-Ev7PMgerhw1DBMMASHvU0nbAtdINlf6gu2bc29XZ7I7cg8Ja6RZ32V9dAWp3KFv_0PypfS34VpE_w" alt /></p>
<p>Click on the Mode Network Server options available on the Upper Left Corner of the Screen to reveal a dropdown list.</p>
<p><img src="https://lh7-us.googleusercontent.com/YjfXepkz-adcV4kqLByc5FJdolSM5X8Tu8NYYOSJHsnyUM75Fkaul7pdC4E8qbOmPAxb7Vnul8dGp0bMS3fyLtlHHiBITZi6HFVhXtCX6M1KKmSO4TYZP3IlKvIHgNRYCZuhHOYxjua-49uQRiqQ96k" alt /></p>
<p>Select <code>Linked Roles</code> in the options menu.</p>
<p><img src="https://lh7-us.googleusercontent.com/cGUuXgkIPMxEb_UmSSRYar5moba3rsX3TLLpmh7bnjmyXVHdm_FFGGhWQ00gYwIZeGwpY5Gg92unF0L93FA8fbqeZgJ0j4m5_eBI4wrAhHyTf53TZUltw7K7oVMaPMNi86n8pY_epepl4YvSVzAA68M" alt /></p>
<p>A Modal with the linked roles will appear. Select <code>Developer</code> from the options. You will be prompted to connect to your GitHub account.</p>
<p><img src="https://lh7-us.googleusercontent.com/JVQEWbVHtwu-EsNZaXmfj7TfC-FmVNiZ1h7iYkf3ZNjxkmVN0egjYKY8qW7BFfLDdEJoiP_rG2uNTA2jmvrj6OMtyK07n2JVSar170V6aWUgFmIm3U2K5tgT_iyudqOpcqWcGplQwAknTcCMLEuR39w" alt /></p>
<p>Once you’ve successfully connected your GitHub account, you will be granted the Developer role.</p>
<p><img src="https://lh7-us.googleusercontent.com/QeSXRFd07KXYTu_QvzABfYZu6_-IeyryCnKLdO3F7y63WTsXMpJifGiaJIS5Bo6DFqMwQeNFF7jrn51SNvT2DuzFr48Ql5B05pq73zvqvh6IUQfyJNtWr0YR0q5AmtyXOMIiwg5t1oKrdEWucN3Tc_M" alt /></p>
<p>Congratulation! You now have access to the developer-exclusive channel. Feel free to ask questions, share what you are building, and connect with other builders.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707329696167/99a685ce-849d-4d10-824b-7eb9451f9fb0.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-whats-next">What's Next</h3>
<ul>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=NuI1cwpCX40&amp;t=194s">How to Bridge Assets over to Mode from other networks</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=bXw2oI_GNrI&amp;feature=youtu.be">How to Register a Smart Contract on Mode using Hardhat</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=rs0czuDlvjc&amp;t=10s">Add Mode to Metamask in One Click</a></p>
</li>
<li><p><a target="_blank" href="https://docs.mode.network">Mode Documentation</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[A Dive into Optimism Bedrock]]></title><description><![CDATA[Optimism bedrock is an upgrade to Optimism blockchain nodes, It acts as a critical "bedrock" for future development.]]></description><link>https://mode.hashnode.dev/a-dive-into-optimism-bedrock</link><guid isPermaLink="true">https://mode.hashnode.dev/a-dive-into-optimism-bedrock</guid><category><![CDATA[Blockchain]]></category><category><![CDATA[Smart Contracts]]></category><dc:creator><![CDATA[The Revealer]]></dc:creator><pubDate>Fri, 26 Jan 2024 10:59:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706228812227/483d7fbf-1699-4788-bbcb-0dcdac15299d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://www.optimism.io/">Optimism</a> is a blockchain ecosystem built for scaling Ethereum, it addresses Ethereum's high gas fees and slow processing times by processing transactions in batches off-chain with the help of an optimistic roll-up and then posting it back to Ethereum’s mainet for security.</p>
<p>In this article, we will be diving into Optimism bedrock, which is a major upgrade to the Optimism blockchain, we will also take a look at the Optimism superchain, the next major addition to the Optimism ecosystem after bedrock.</p>
<h2 id="heading-what-is-optimism-bedrock"><strong>What is Optimism Bedrock?</strong></h2>
<p>Optimism bedrock is an upgrade to Optimism blockchain nodes, It acts as a critical "bedrock" for future development, aiming to improve efficiency, security, and flexibility. Bedrock’s features aim to make Optimism the cheapest, fastest, and most advanced rollup architecture.</p>
<p>Some of the features considered when it was built and designed are upgradeability and modularity. Upgrades no longer have to be monolithic but done seamlessly without disruption while allowing the addition of new features.</p>
<p>Bedrock’s modularity was built with developers in mind. Now they can pick and choose modules like Lego blocks to build customized Layer 2s on top of Optimism, Instead of one monolithic blockchain, you have smaller, specialized components working together seamlessly.</p>
<h3 id="heading-what-are-optimism-bedrock-upgrades"><strong>What are Optimism Bedrock Upgrades?</strong></h3>
<p>Some of the main changes that Bedrocks brings to the Optimism blockchain include;</p>
<ol>
<li><p><strong>Lower gas Fees</strong></p>
<p> Bedrock achieves this by removing Layer 1(Ethereum blockchain) execution gas, reducing the data fees for Layer 1. This change reduces gas fees by an overall 10% compared to the protocol's previous version.</p>
</li>
<li><p><strong>Faster deposit times</strong></p>
<p> Bedrock reduces the time it takes to deposit transactions to 3 minutes by introducing block re-organization (Confirmation depth is reduced to 10-12 blocks for Layer 1). This is much faster compared to the previous version which takes about 10 minutes.</p>
</li>
<li><p><strong>Ethereum Equivalence</strong></p>
<p> Bedrock aims to be the most advanced rollup there is by incorporating all of Ethereum’s code, infrastructure, and design patterns into its architecture, making it as close as possible to Ethereum.</p>
<p> Examples of the Ethereum Equivalent features in Bedrock include;</p>
<ul>
<li><p>A Separation between the execution and consensus layer.</p>
</li>
<li><p>Support for alternative and multiple node client implementations.</p>
</li>
<li><p>Support for the EIP-1559.</p>
</li>
<li><p>Support for a private mempool for Optimism sequencer to process pending transactions.</p>
</li>
</ul>
</li>
<li><p><strong>Improved Block production</strong></p>
<p> Bedrock improves node performance and block production by removing one transaction per block model and now allows several transactions in a single block.</p>
</li>
</ol>
<h2 id="heading-what-is-optimism-superchain"><strong>What is Optimism Superchain?</strong></h2>
<p>The Superchain is a network of layer 2 blockchains that share a common communication layer, bridging, and decentralized governance which is all built on the OP-Stack ( A toolkit for building Optimistic rollup-based layer 2 blockchains).</p>
<p>Instead of creating isolated scaling solutions, the Superchain aims to have a network of unified blockchains that aims to provide a scalable and secure web3 ecosystem while sharing the infrastructure and benefits of the Optimism rollup architecture.</p>
<h3 id="heading-how-does-the-superchain-work"><strong>How does the Superchain work?</strong></h3>
<p>Bedrock was the first major step toward achieving the goal of a unified network of chains on the OP-Stack. But, how does it work?</p>
<ol>
<li><p><strong>Horizontal Scalability</strong>: Unlike vertical scaling on a single chain, Superchain facilitates horizontal growth by adding new OP Chains as needed. This allows for the distribution of different applications and user loads across the network, significantly increasing transaction throughput and reducing congestion.</p>
</li>
<li><p><strong>Shared Security</strong>: Security remains a critical aspect. The Superchain leverages a shared validator pool, where a set of chosen validators secure all OP Chains in the network. This means the security of each chain is backed by the combined power of the entire Superchain, even though smaller chains may have lower fees.</p>
</li>
<li><p><strong>Communication Layer</strong>: To enable seamless communication and data exchange between OP Chains, a dedicated communication layer sits between them. This allows applications to easily interact with users and data across different chains, fostering a truly unified ecosystem.</p>
</li>
<li><p><strong>Decentralized Governance</strong>: The Superchain is governed by the Optimism Collective, a decentralized organization made up of token holders and stakeholders. They vote on key decisions like adding new chains, upgrading the OP Stack, and allocating resources. This ensures the Superchain remains community-driven and evolves according to its users' needs.</p>
</li>
</ol>
<p><img src="https://lh7-us.googleusercontent.com/Y5pSrsnM492kJ01eKi5oeSCiZAR9aG79FOUkZXhG8ckTZB-O8v_NyxD1Nk9Ax29Ni6u6K6szCx5zUlfy-jHG_Ne0EHQFOAd0siHt3SOGFi6nsPgXV9aDFhh81WRgzz1WXvUXlUlKvDlfQ0KPxaOXNkw" alt /></p>
<p><a target="_blank" href="https://docs.optimism.io/stack/explainer#superchain-overview"><em>The superchain at a glance</em></a></p>
<h3 id="heading-build-with-mode"><strong>Build with Mode</strong></h3>
<p><a target="_blank" href="https://www.mode.network/">Mode Network</a> is a superchain built on the OP-Stack, It was built to support and encourage a cooperative on-chain experience for builders and users. One way which mode empowers its community is through the Sequencer fee Sharing and the User Referral Fees, this initiative allows builders and users to grow as the network grows.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706229035492/9ef80b4e-8d01-4bc5-ab1c-d482c7347220.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>Optimism Bedrock has laid a solid foundation for the Optimism Superchain, a powerful vision for scalable and interoperable blockchain networks. By achieving significant reductions in gas fees, faster transaction times, and enhanced security, Bedrock has removed key barriers to widespread adoption.</p>
<p>Mode Network, built on the OP Stack, stands as a testament to the power of cooperation within the Superchain ecosystem. And, through innovative features like Sequencer Fee Sharing and User Referral Fees, Mode fosters an environment where builders and users can grow and thrive.</p>
<p>If you're ready to be a part of this, join the <a target="_blank" href="https://discord.com/invite/modenetworkofficial">Mode community</a> to learn more about how to turn your code into a thriving on-chain business.</p>
]]></content:encoded></item><item><title><![CDATA[Assign a smart contract to an existing SFS NFT with Thirdweb deployment]]></title><description><![CDATA[Thirdweb is a web3 platform that provides developers with tools to build, deploy, launch, and manage their applications and games. Some of these tools…]]></description><link>https://mode.hashnode.dev/assign-a-smart-contract-to-an-existing-sfs-nft-with-thirdweb-deployment</link><guid isPermaLink="true">https://mode.hashnode.dev/assign-a-smart-contract-to-an-existing-sfs-nft-with-thirdweb-deployment</guid><dc:creator><![CDATA[Olayinka Oshidipe]]></dc:creator><pubDate>Thu, 25 Jan 2024 17:14:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706202727912/dd7728c3-5c92-4d0e-80fa-abcca2faa47d.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Thirdweb is a web3 platform that provides developers with tools to build, deploy, launch, and manage their applications and games. Some of these tools include pre-built smart contracts, SDKs, and APIs.</p>
<p>In this tutorial, you’ll learn how to assign a smart contract to Mode Network’s SFS (<strong>Sequencer Fee Sharing</strong>) Contract by deploying with thirdweb.</p>
<p><strong>Prerequisites</strong></p>
<p>Before you continue with this tutorial you should:</p>
<ol>
<li><p>A  <a target="_blank" href="https://metamask.io/">Metamask</a> Account.</p>
</li>
<li><p>Latest version of <a target="_blank" href="https://nodejs.org/en">Node</a> and <a target="_blank" href="https://yarnpkg.com/">Yarn</a></p>
</li>
<li><p>A <a target="_blank" href="https://thirdweb.com/">thirdweb</a> account.</p>
</li>
<li><p>Basic understanding of <a target="_blank" href="https://soliditylang.org/">Solidity</a>.</p>
</li>
<li><p><a target="_blank" href="https://docs.mode.network/mode-testnet/bridging-to-mode-testnet">Bridge</a> Sepolia Eth with Mode Network.</p>
</li>
<li><p>An SFS NFT token Id.</p>
</li>
</ol>
<h1 id="heading-sequencer-fee-sharing-sfs-on-mode-network">Sequencer Fee Sharing (SFS) on Mode Network</h1>
<p>Sequencer Fee Sharing (SFS) stands out as a pivotal feature within the Mode network, empowering developers to earn a percentage of transaction fees originating from their smart contracts' activities. This section guides you through the process of leveraging SFS for your smart contract within the Mode ecosystem.</p>
<p><strong>Registration and ERC 721 NFT</strong></p>
<p>To kickstart the fee-sharing mechanism, your smart contract needs to be registered with Mode's SFS contract. This registration is the gateway to unlocking the benefits of fee-sharing. Upon successful registration, you'll receive an ERC 721 Non-Fungible Token (NFT). This unique token serves as your exclusive claim to transaction fees generated by your contract.</p>
<p><strong>Transferable and Multipurpose SFS NFT</strong></p>
<p>The SFS NFT isn't limited to a single smart contract. It's both transferable and versatile, allowing you to utilize it across multiple contracts or share it between existing contracts. Whether you deploy new smart contracts on Mode or manage multiple contracts under a single SFS NFT, this flexibility caters to your specific needs.</p>
<p><strong>Fee Processing and Accumulation Period</strong></p>
<p>As your smart contract operates within the Mode network, an off-chain component takes charge of processing transactions and calculating your share of fees. It's important to be aware of a two-week accumulation period during which fees accrue before being transferred to the SFS contract.</p>
<p><strong>Claiming Rewards</strong></p>
<p>Once the fees are successfully transferred to the SFS contract, you can easily claim your accumulated rewards. This process not only acknowledges your contribution to the network but also aligns with Mode's commitment to incentivizing innovation and utilization of smart contracts within the ecosystem.</p>
<p><strong>Explore the SFS Contract Code</strong></p>
<p>For a deeper understanding and exploration of the SFS contract code, please refer to the [complete SFS contract code here](link-to-SFS-contract-code). Sequencer Fee Sharing is designed to streamline and enhance your experience as a developer on Mode Network, ensuring that you're duly rewarded for your contributions.</p>
<h2 id="heading-assigning-smart-contract-to-an-existing-sfs-nft"><strong>Assigning smart contract to an existing SFS NFT</strong></h2>
<p>Let’s take a look at the assign function in the SFS contract to understand how the assignment works.</p>
<p>Note that this is only a portion of the SFS contract, <a target="_blank" href="https://sepolia.explorer.mode.network/address/0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6?tab=contract">check here</a> to see the complete code.</p>
<pre><code class="lang-solidity"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">assign</span>(<span class="hljs-params"><span class="hljs-keyword">uint256</span> _tokenId</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title">onlyUnregistered</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">address</span> smartContract <span class="hljs-operator">=</span> <span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>;

       <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>_exists(_tokenId)) <span class="hljs-keyword">revert</span> InvalidTokenId();

       <span class="hljs-keyword">emit</span> Assign(smartContract, _tokenId);

       feeRecipient[smartContract] <span class="hljs-operator">=</span> NftData({

           tokenId: _tokenId,

           registered: <span class="hljs-literal">true</span>,

           balanceUpdatedBlock: <span class="hljs-built_in">block</span>.<span class="hljs-built_in">number</span>

       });

       <span class="hljs-keyword">return</span> _tokenId;

   }
</code></pre>
<p>This function takes <strong>_tokenId</strong> as an input parameter. Subsequently, it verifies the validity of the tokenId before emitting an Assign event. Following this event, the <strong>msg.sender</strong> (our smart contract) gets associated with the tokenId in the SFS. It updates the feeRecipient mapping with relevant information.</p>
<p><strong>Here are a few points to keep in mind:</strong></p>
<ul>
<li><p>The assign function is declared as public, allowing an external smart contract to invoke it.</p>
</li>
<li><p>The assumption is that msg.sender represents a smart contract address, as this function is intended to be called by a smart contract.</p>
</li>
<li><p>The assign function does not generate an ownership NFT; instead, it links your smart contract to an existing SFS NFT.</p>
</li>
<li><p>The process of assigning a smart contract to an SFS NFT is a one-time operation.</p>
</li>
</ul>
<p>Now that we comprehend the workings of the assign function, let's proceed to set up our project and construct our smart contract.</p>
<h1 id="heading-setting-up-our-project"><strong>Setting Up Our Project</strong></h1>
<p>To set up our project, we need to set up a few things.</p>
<h3 id="heading-1-download-the-thirdweb-cli"><strong>1. Download the ThirdWeb CLI</strong></h3>
<p>To install thirdweb globally, open your terminal and run</p>
<p><code>npm i -g thirdweb</code></p>
<p>Now try running:</p>
<p><code>thirdweb --version</code></p>
<p>If the CLI is installed correctly you will be prompted to go to the installed version</p>
<h3 id="heading-2-create-a-local-environment"><strong>2. Create a Local environment</strong></h3>
<p>Create a new project by running</p>
<p><code>npx thirdweb create contract</code></p>
<p><em>You will be prompted with a menu with different options for setting up your project. We will select ‘Empty Contract’ and write our Smart Contract Code from scratch.</em></p>
<p><img src="https://lh7-us.googleusercontent.com/S6BWnVdV0ZbuiAMbUNp9PWvOLzdX-X5UPvN7rtw8LU-mTcNGAOp9qChkv5fPHgaSOyfv0fC4NM4ccerr1ZdCpzcIMg4OTpPKkjHVcFAEI1YEEOJ6ovWygQKWwV6VyLDrT2A2p9hDXyAmFsQ7fPfblG0" alt /></p>
<p><em>Once thirdweb is done building our project, we’ll run</em></p>
<p><code>cd project-name &amp;&amp; code .</code></p>
<p>To open with vscode.</p>
<p><strong>3. Writing Our Smart Contract</strong></p>
<p>Navigate to the "contracts" directory within your project. Specifically for this tutorial, we will be working with a straightforward <strong>Hello World</strong> Contract.</p>
<p>First, we added the SFS contract to our file with a register function. Then in the constructor, we invoked the assign function by initializing a new instance of our SFS contract and calling the assign method on it.</p>
<p>We’ll create a new file and call it: <strong>Contract.sol</strong></p>
<p>And paste the below code into it.</p>
<pre><code class="lang-solidity"><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.9;</span>

<span class="hljs-comment">//Here we created our SFS contract</span>

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">SFS</span> </span>{
   <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">assign</span>(<span class="hljs-params"><span class="hljs-keyword">uint256</span> _tokenId</span>) <span class="hljs-title"><span class="hljs-keyword">public</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-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">HelloWorld</span> </span>{
   <span class="hljs-keyword">string</span> <span class="hljs-keyword">public</span> greeting;
   <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) </span>{
       greeting <span class="hljs-operator">=</span> <span class="hljs-string">"Hello, World!"</span>;
       SFS sfsContract <span class="hljs-operator">=</span> SFS(<span class="hljs-number">0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6</span>);
       sfsContract.assign(<span class="hljs-number">45</span>);
   }

   <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getGreeting</span>(<span class="hljs-params"></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">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span></span>) </span>{
       <span class="hljs-keyword">return</span> greeting;
   }

   <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">setGreeting</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> newGreeting</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
       greeting <span class="hljs-operator">=</span> newGreeting;

   }
}
</code></pre>
<p>Remember to change the <strong>ID (45)</strong> inside of <em>sfsContract.assign(<strong><strong>45</strong></strong>)</em> to the ID of your NFT. Save your file.</p>
<p><strong>NOTE:</strong></p>
<p>Mode SFS contact has a different address for Mainnet and Testnet and for this tutorial, we’re deploying to Testnet so we’re going to register to the Testnet's SFS contract.</p>
<p>Mainnet SFS Address: <strong>0x8680CEaBcb9b56913c519c069Add6Bc3494B7020</strong></p>
<p>Testnet SFS Address: <strong>0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6</strong></p>
<p>Thirdweb requires an API key to monitor your smart contracts, check out this tutorial on creating a <a target="_blank" href="https://docs.mode.network/build-on-mode/tutorials/deploying-a-smart-contract/using-thirdweb#3.-create-a-thirdweb-api-key">Thirdweb API Key</a> to get it done.</p>
<h1 id="heading-deploying-our-contract-to-thirdweb"><strong>Deploying Our Contract to Thirdweb</strong></h1>
<h1 id="heading-step-1"><strong>STEP 1</strong></h1>
<p>Navigate to the project root and run either of the following commands:</p>
<p><code>yarn deploy</code></p>
<p>or</p>
<p><code>npx thirdweb deploy</code></p>
<p>You will then be directed to your thirdweb dashboard.</p>
<p>Select Mode Testnet as the network of your choice.</p>
<h2 id="heading-step-2"><strong>STEP 2</strong></h2>
<p>Choose Mode Testnet as the network, click on <strong>deploy</strong>, confirm and then sign the transaction from Metamask to complete it.</p>
<p><img src="https://lh7-us.googleusercontent.com/wJ8rYisRTI4SqE6bzpeke_ebtQ1FDSXnP8RQct4jVkBA-0TrtmgRpq_v7I0HBmu0vLoc8jjd-48mBxfiPbE7E4cR_u3Tk_LwFM_8RnnfG8HSIRlT67Y9yLOzxR_KIpw7u9X2-zcH5ufP8m-QTSSGBtY" alt /></p>
<p>If successful, you'll see a "<strong>Success</strong>" message.</p>
<p><img src="https://lh7-us.googleusercontent.com/KRdjojkTZmrDYK_OEtd4f3qCbuhBDoMFtUB4TwIJJSVDiVdx2inWj9Jtqi6YSn-4oTUFnVAyjv1sWPBy_-DWgkqvTbLzYm6EdueTCq--jyTZEzAN6_8nsz2DA2EERcTLgIvKD9z96znoKJbVWb0eJds" alt /></p>
<p>Congratulations! You've deployed and assigned your contract to an existing NFT with Thirdweb. Feel free to explore your dashboard for code details, contract events, and more.</p>
]]></content:encoded></item><item><title><![CDATA[How to Register a Smart Contract to Mode SFS with Hardhat.]]></title><description><![CDATA[Hardhat is an Ethereum development framework for creating, testing and deploying smart contracts. It includes a suite of tools that aid in developing smart…]]></description><link>https://mode.hashnode.dev/how-to-register-a-smart-contract-to-mode-sfs-with-hardhat</link><guid isPermaLink="true">https://mode.hashnode.dev/how-to-register-a-smart-contract-to-mode-sfs-with-hardhat</guid><category><![CDATA[Smart Contracts]]></category><category><![CDATA[Blockchain]]></category><dc:creator><![CDATA[The Revealer]]></dc:creator><pubDate>Fri, 19 Jan 2024 00:54:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706228382790/d8932881-0e51-4f1e-8d27-3e852f55a7f7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://hardhat.org/">Hardhat</a> is an Ethereum development framework for creating, testing and deploying smart contracts. It includes a suite of tools that aid in developing smart contracts and managing the complete development process, allowing developers to write scripts, compile, test, and deploy efficiently.</p>
<p>In this tutorial, you will learn how to register a smart contract to Mode Network’s SFS (Sequencer Fee Sharing) contract with Hardhat.</p>
<h3 id="heading-prerequisites"><strong>Prerequisites</strong></h3>
<p>Before you continue with this tutorial, you should:</p>
<ol>
<li><p>Have <a target="_blank" href="https://www.npmjs.com/">npm</a> and <a target="_blank" href="https://nodejs.org/en">node.js</a> installed with the recommended versions.</p>
</li>
<li><p>Have an Ethereum wallet, preferably <a target="_blank" href="https://metamask.io/">Metamask</a> installed.</p>
</li>
<li><p>Have a basic understanding of <a target="_blank" href="https://soliditylang.org/">Solidity</a>.</p>
</li>
<li><p><a target="_blank" href="https://docs.mode.network/mode-testnet/bridging-to-mode-testnet">Bridge</a> Sepolia Eth with Mode Network.</p>
</li>
</ol>
<h2 id="heading-what-is-sequencer-fee-sharing-sfs">What is Sequencer Fee Sharing (SFS)?</h2>
<p>The SFS contract allows developers to earn a portion of the transaction fees from transactions running on their contract when deployed and registered on Mode Network. The SFS contract implements this functionality and permits other contracts to register and earn.</p>
<p>To register, your smart contract has to make a call to the SFS contract; after this is done successfully, you will be issued an NFT (non-fungible token). This NFT allows you to claim your fees accumulated in the SFS contract.</p>
<h2 id="heading-how-does-the-sfs-register-function-work">How does the SFS Register function work?</h2>
<p>Let’s look at the SFS contract's register function to understand how the registration works.</p>
<p>Note that this is only a portion of the SFS contract; <a target="_blank" href="https://sepolia.explorer.mode.network/address/0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6?tab=contract">check here</a> to see the complete code.</p>
<pre><code class="lang-solidity"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">register</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> _recipient</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title">onlyUnregistered</span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint256</span> tokenId</span>)</span>{
<span class="hljs-keyword">address</span> smartContract <span class="hljs-operator">=</span> <span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>;

<span class="hljs-comment">// Check if the recipient address is valid; revert if it's null</span>
<span class="hljs-keyword">if</span> (_recipient <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-keyword">revert</span> InvalidRecipient();

<span class="hljs-comment">// Generate a unique tokenId, mint an NFT to the recipient with it,</span>
<span class="hljs-comment">// and update </span>
   tokenId <span class="hljs-operator">=</span> _tokenIdTracker.current();
   _mint(_recipient, tokenId);
   _tokenIdTracker.increment();

<span class="hljs-keyword">emit</span> Register(smartContract, _recipient, tokenId);
<span class="hljs-comment">// Update the fee recipient mapping for the smart contract,</span>
<span class="hljs-comment">// associating it with the tokenId and registration details</span>
 feeRecipient[smartContract] <span class="hljs-operator">=</span> NftData({
       tokenId: tokenId,
       registered: <span class="hljs-literal">true</span>,
       balanceUpdatedBlock: <span class="hljs-built_in">block</span>.<span class="hljs-built_in">number</span>
   });
}
</code></pre>
<p>This function receives <code>"_recipient"</code> as input and then mints an NFT to this recipient once your smart contract is registered.</p>
<p>Then, the <code>msg.sender</code> is picked up as the contract to register in the SFS updating the mapping with relevant information.</p>
<p><strong>Here are a few things to note:</strong></p>
<ul>
<li><p>The Function is specified public meaning an external smart contract can call it.</p>
</li>
<li><p>The <code>msg.sender</code> is assumed to be a smart contract address, ensuring that a smart contract can register a fee recipient.</p>
</li>
<li><p>The Function mints an ownership NFT that allows the owner to claim fees earned by the recipient smart contract.</p>
</li>
</ul>
<p>Now that we’ve understood how the register function works, let’s set up our project.</p>
<h3 id="heading-1-setting-up-our-project">1. Setting Up Our Project</h3>
<p>Open your terminal to create a new directory for your project.</p>
<p><code>mkdir hardhat</code></p>
<p>Navigate into your project</p>
<p><code>cd hardhat</code></p>
<p>Initialize an npm project - This creates your package.json file.</p>
<p><code>npm init -y</code></p>
<p><code>Install hardhat</code></p>
<p><code>npm install --save-dev hardhat</code></p>
<p>To create your project run</p>
<p><code>npx hardhat init</code></p>
<p><strong>When prompted make these selections:</strong></p>
<ul>
<li><p>Choose "Create a TypeScript project".</p>
</li>
<li><p>For the .gitignore prompt, select "Yes" (or y).</p>
</li>
<li><p>Select "Yes" (or y) to install the project's dependencies</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1705158647887/ad3ddab9-d4cc-4356-8aa2-d61462963376.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-2-writing-our-smart-contract">2. Writing our smart contract</h3>
<p>Head to the contracts folder of your project, for the sake of this tutorial we will be using the contract provided by Hardhat.</p>
<p>Rename the file named <code>lock.sol</code> to any name of your choice then add the register contract to your file and the register function to your constructor.</p>
<pre><code class="lang-solidity"><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.9;</span>
<span class="hljs-comment">// Add this</span>
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Register</span> </span>{
   <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">register</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> _recipient</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint256</span> tokenId</span>) </span>{}
}
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Lock</span> </span>{
   <span class="hljs-keyword">uint</span> <span class="hljs-keyword">public</span> unlockTime;
   <span class="hljs-keyword">address</span> <span class="hljs-keyword">payable</span> <span class="hljs-keyword">public</span> owner;
   <span class="hljs-function"><span class="hljs-keyword">event</span> <span class="hljs-title">Withdrawal</span>(<span class="hljs-params"><span class="hljs-keyword">uint</span> amount, <span class="hljs-keyword">uint</span> when</span>)</span>;

   <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">uint</span> _unlockTime</span>) <span class="hljs-title"><span class="hljs-keyword">payable</span></span> </span>{
       <span class="hljs-built_in">require</span>(
           <span class="hljs-built_in">block</span>.<span class="hljs-built_in">timestamp</span> <span class="hljs-operator">&lt;</span> _unlockTime,
           <span class="hljs-string">"Unlock time should be in the future"</span>
       );
       unlockTime <span class="hljs-operator">=</span> _unlockTime;
       owner <span class="hljs-operator">=</span> <span class="hljs-keyword">payable</span>(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>);
    <span class="hljs-comment">//Add this</span>
       Register sfsContract <span class="hljs-operator">=</span> Register(<span class="hljs-number">0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6</span>);
       sfsContract.register(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>); <span class="hljs-comment">//</span>
   }

   <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">withdraw</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
       <span class="hljs-built_in">require</span>(<span class="hljs-built_in">block</span>.<span class="hljs-built_in">timestamp</span> <span class="hljs-operator">&gt;</span><span class="hljs-operator">=</span> unlockTime, <span class="hljs-string">"You can't withdraw yet"</span>);
       <span class="hljs-built_in">require</span>(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> owner, <span class="hljs-string">"You aren't the owner"</span>);

       <span class="hljs-keyword">emit</span> Withdrawal(<span class="hljs-keyword">address</span>(<span class="hljs-built_in">this</span>).<span class="hljs-built_in">balance</span>, <span class="hljs-built_in">block</span>.<span class="hljs-built_in">timestamp</span>);

       owner.<span class="hljs-built_in">transfer</span>(<span class="hljs-keyword">address</span>(<span class="hljs-built_in">this</span>).<span class="hljs-built_in">balance</span>);
   }
}
</code></pre>
<h3 id="heading-3-configuring-hardhat-for-mode">3. Configuring Hardhat for Mode</h3>
<p>Head to the <code>hardhat.config.ts</code> file and replace it with this code to set Mode Network Testnet.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> { HardhatUserConfig } <span class="hljs-keyword">from</span> <span class="hljs-string">"hardhat/config"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"@nomicfoundation/hardhat-toolbox"</span>;

<span class="hljs-keyword">const</span> config: HardhatUserConfig = {
 networks: {
   mode: {
     url: <span class="hljs-string">"https://sepolia.mode.network"</span>,
     chainId: <span class="hljs-number">919</span>,
     accounts: [<span class="hljs-string">"YOUR_METAMASK_PRIVATE_KEY_HERE"</span>] <span class="hljs-comment">//DO NOT PUSH THIS TO GITHUB</span>
   }
 },
 solidity: <span class="hljs-string">"0.8.9"</span>,
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> config;
</code></pre>
<h3 id="heading-4-compiling-our-contract">4. Compiling our contract</h3>
<p>To compile the smart contract run</p>
<p><code>npx hardhat compile</code></p>
<p>It would return;</p>
<p><code>Successfully generated 8 typings!</code></p>
<p><code>Compiled 1 Solidity file successfully (evm target: london).</code></p>
<h3 id="heading-5-deploying">5. Deploying</h3>
<p>To deploy we will make use of the deploy.ts file in the scripts folder, we won’t be changing anything because we didn’t change our smart contract.</p>
<p>To deploy the smart contract to Mode Testnet run</p>
<p><code>npx hardhat run scripts/deploy.ts --network mode</code></p>
<p>It returns</p>
<p><code>Lock with 0.001ETH and unlock timestamp 1702421602 deployed to 0x6900A6158C1BD0C61F1E6a191B1f822EA000E2e8</code></p>
<p>Congratulations! You just deployed and registered your contract with Hardhat and Typescript.</p>
<h2 id="heading-check-the-explorer">Check the Explorer</h2>
<p>To view your transaction head to <a target="_blank" href="https://sepolia.explorer.mode.network/">Mode Testnet</a> and paste the contract address.</p>
<p>Your contract should be registered and your NFT minted.</p>
<p>To import the NFT to your wallet, check our <a target="_blank" href="https://docs.mode.network/build-on-mode/tutorials/sfs-sequencer-fee-sharing/sfs-check-the-registry#adding-the-sfs-nft-to-your-wallet">Adding the SFS NFT to your wallet</a> tutorial.</p>
<p>To learn more about mode and how to turn your code into a business join our Discord and say hi.</p>
<p>To learn more about mode and how to turn your code into a business join our <a target="_blank" href="https://discord.com/invite/modenetworkofficial">Discord</a> and say hi.</p>
]]></content:encoded></item><item><title><![CDATA[How to Register a Smart Contract to Mode SFS with Thirdweb]]></title><description><![CDATA[Thirdweb is a web3 platform that provides developers with tools to build, deploy, launch, and manage their applications and games. Some of these tools…]]></description><link>https://mode.hashnode.dev/how-to-register-a-smart-contract-to-mode-sfs-with-thirdweb</link><guid isPermaLink="true">https://mode.hashnode.dev/how-to-register-a-smart-contract-to-mode-sfs-with-thirdweb</guid><category><![CDATA[Smart Contracts]]></category><category><![CDATA[Blockchain]]></category><dc:creator><![CDATA[The Revealer]]></dc:creator><pubDate>Fri, 19 Jan 2024 00:54:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706228289461/f1e5b41a-6e7d-4469-97ed-5f6055cb3af5.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://thirdweb.com/">Thirdweb</a> is a web3 platform that provides developers with tools to build, deploy, launch, and manage their applications and games. Some of these tools include pre-built smart contracts, SDKs, and APIs.</p>
<p>In this tutorial, you will learn how to register a smart contract to Mode Network’s SFS (Sequencer Fee Sharing) Contract while deploying with Thirdweb.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before you continue with this tutorial you should:</p>
<ul>
<li><p>Create a <a target="_blank" href="https://thirdweb.com/">thirdweb</a> account.</p>
</li>
<li><p>Have a basic understanding of <a target="_blank" href="https://soliditylang.org/">Solidity</a>.</p>
</li>
<li><p><a target="_blank" href="https://docs.mode.network/mode-testnet/bridging-to-mode-testnet">Bridge</a> Sepolia Eth with Mode Network.</p>
</li>
<li><p>Have <a target="_blank" href="https://nodejs.org/en">Node</a> and <a target="_blank" href="https://yarnpkg.com/">Yarn</a> installed with a recent version.</p>
</li>
</ul>
<h2 id="heading-what-is-sequencer-fee-sharing-sfs">What is Sequencer Fee Sharing (SFS)?</h2>
<p>Picture this! When you deploy your smart contract to Mode Network, you will be able to receive a percentage of the transaction fees associated with your smart contract. In other words, you get a share of the transaction fees when transactions are made on your contract, rewarding your contribution to the network and incentivizing further innovation and usage of your smart contract.</p>
<p>But, how does this work?</p>
<p>You must register your contract with Mode Network's <a target="_blank" href="https://sepolia.explorer.mode.network/address/0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6">Registry/SFS contract</a>. When you register, the Registry contract issues you an NFT as a claim to earned fees. The call to register your contract must come from your contract.</p>
<p>Also, an off-chain component is responsible for processing transactions and calculating your share of fees from each transaction. Your minted NFT allows you to claim your fees accumulated in the SFS contract. One thing to keep in mind is that there would be a two-week time for the fees to accumulate before being transferred to the SFS contract. When this is done you can withdraw your rewards..</p>
<h2 id="heading-how-does-the-sfs-register-function-work">How does the SFS Register function work?</h2>
<p>We mentioned earlier that the call to register to the SFS needs to come directly from the smart contract you want to register. To understand how this all works, let’s look at the register function.</p>
<p>Note that this is only a portion of the SFS contract, <a target="_blank" href="https://sepolia.explorer.mode.network/address/0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6?tab=contract">check here</a> to see the complete code.</p>
<pre><code class="lang-solidity"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">register</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> _recipient</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title">onlyUnregistered</span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint256</span> tokenId</span>) </span>{
   <span class="hljs-keyword">address</span> smartContract <span class="hljs-operator">=</span> <span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>;


<span class="hljs-comment">// Check if the recipient address is valid; revert if it's null</span>
   <span class="hljs-keyword">if</span> (_recipient <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-keyword">revert</span> InvalidRecipient();

<span class="hljs-comment">// Generate a unique tokenId, mint an NFT to the recipient with it, and update         //the tracker</span>
   tokenId <span class="hljs-operator">=</span> _tokenIdTracker.current();
   _mint(_recipient, tokenId);
   _tokenIdTracker.increment();


   <span class="hljs-keyword">emit</span> Register(smartContract, _recipient, tokenId);


<span class="hljs-comment">// Update the fee recipient mapping for the smart contract, associating it with //the tokenId and registration details</span>
   feeRecipient[smartContract] <span class="hljs-operator">=</span> NftData({
       tokenId: tokenId,
       registered: <span class="hljs-literal">true</span>,
       balanceUpdatedBlock: <span class="hljs-built_in">block</span>.<span class="hljs-built_in">number</span>
   });
}
</code></pre>
<p>This is a function that receives "<code>_recipient</code>" as an input and then mints an NFT to this recipient once your smart contract is registered.</p>
<p>Then, the <code>msg. sender</code> is picked up as the contract to register in the SFS updating the mapping with relevant information.</p>
<p>Here are a few things to note;</p>
<ul>
<li><p>The Function is specified <code>public</code> meaning an external smart contract can call it.</p>
</li>
<li><p>The <code>msg.sender</code> is assumed to be a smart contract address, ensuring that a smart contract can register a fee recipient.</p>
</li>
<li><p>The Function mints an ownership NFT that allows the owner to claim fees earned by the recipient smart contract.</p>
</li>
</ul>
<h2 id="heading-the-register-function-in-practice">The Register Function in Practice</h2>
<p>Let's take a look at an example to solidify our understanding;</p>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</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">"@thirdweb-dev/contracts/base/ERC20Vote.sol"</span>;


<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Register</span> </span>{
   <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">register</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> _recipient</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint256</span> tokenId</span>) </span>{}
}


<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Contract</span> <span class="hljs-keyword">is</span> <span class="hljs-title">ERC20Vote</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params">
      <span class="hljs-keyword">address</span> _defaultAdmin,
      <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">ERC20Vote</span>(<span class="hljs-params">
          _defaultAdmin,
          _name,
          _symbol
      </span>)
   </span>{
       Register sfsContract <span class="hljs-operator">=</span> Register(<span class="hljs-number">0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6</span>);
       sfsContract.register(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>);
   }
}
</code></pre>
<p>We used a simple ERC20 Vote contract provided with a thirdweb extension which our contract inherits from.</p>
<p>Here are some things to note:</p>
<ul>
<li><p>Our code defines two contracts the Register and Contract.</p>
</li>
<li><p>Our contract inherits properties from the ERC20 Vote contract from thirdweb.</p>
</li>
<li><p>We made an instance of the Register contract and called its register function with the sender’s address ( <code>msg.sender</code>) from the constructor.</p>
</li>
</ul>
<h2 id="heading-deploying-our-contract-to-thirdweb">Deploying Our Contract to Thirdweb</h2>
<p>We will go through the process of installing the CLI, but If you encounter any issues visit the <a target="_blank" href="https://portal.thirdweb.com/cli">official documentation</a>.</p>
<h3 id="heading-1-download-the-thirdweb-cli">1. Download the ThirdWeb CLI</h3>
<p>To install thirdweb globally, open your terminal and run</p>
<p><code>npm i -g thirdweb</code></p>
<p>Now try running:</p>
<p><code>thirdweb --version</code></p>
<p>If the CLI is installed correctly you will be prompted to go to the installed version</p>
<h3 id="heading-2-create-a-local-environment">2. Create a Local environment</h3>
<p>Create a new project by running</p>
<p><code>npx thirdweb create contract</code></p>
<p>You will be prompted to a menu with different options for setting up your project. For the sake of this tutorial, we will make use of an ERC20 contract.</p>
<p>However, feel free to select an Empty Contract and write your code from scratch.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1705158083110/9385aafe-c4c6-4ab0-9c7c-c5fcbb92de36.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-3-deploy">3. Deploy</h3>
<p>Before deploying, thirdweb requires an API key to monitor your smart contracts, check out this tutorial on creating a <a target="_blank" href="https://docs.mode.network/build-on-mode/tutorials/deploying-a-smart-contract/using-thirdweb#3.-create-a-thirdweb-api-key">Thirdweb API Key</a> to get it done.</p>
<h4 id="heading-step-1">STEP 1</h4>
<p>Navigate to the root of your project and in a terminal run the following:</p>
<p><code>Yarn deploy</code> or</p>
<p><code>Npx thirdweb deploy</code></p>
<p>You will be directed to your thirdweb dashboard.</p>
<p>Before deploying, fill in the parameters for the name and symbol of your token</p>
<p>Select Mode Testnet as the network of your choice.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1705158301338/b11e7ad0-f82b-4951-8cd3-ffbf827334a7.png" alt class="image--center mx-auto" /></p>
<h4 id="heading-step-2">STEP 2</h4>
<p>Click on deploy and sign the transaction from your Metamask to complete it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1705158393130/f00469b1-b112-4fd1-92f7-bc92b4d9b494.png" alt class="image--center mx-auto" /></p>
<p>If everything goes well, you should be prompted with this message ”Success”.</p>
<p>Congratulations! You just deployed and registered your contract. From your dashboard, you can read your code, monitor events from your contracts, and many more things.</p>
<p>Our contract should be registered, and the owner address we set as the recipient should have the NFT minted.</p>
<p>To import the NFT to your wallet, check our <a target="_blank" href="https://docs.mode.network/build-on-mode/tutorials/sfs-sequencer-fee-sharing/sfs-check-the-registry#adding-the-sfs-nft-to-your-wallet">Adding SFS NFT to Wallet tutorial.</a></p>
]]></content:encoded></item><item><title><![CDATA[Interacting with Smart Contracts using ethers.js]]></title><description><![CDATA[How to interact with smart contracts deployed on Mode from a frontend using ethers.js]]></description><link>https://mode.hashnode.dev/interacting-with-smart-contracts-using-ethersjs</link><guid isPermaLink="true">https://mode.hashnode.dev/interacting-with-smart-contracts-using-ethersjs</guid><dc:creator><![CDATA[Joshua Nwankwo]]></dc:creator><pubDate>Thu, 11 Jan 2024 09:43:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1705951881658/eac91e00-632b-40c6-b54f-6b2b188793b7.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this tutorial, we'll walk through setting up a basic web app, deploying a smart contract on MODE Network's testnet, and interacting with it using ethers.js.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">If you want a quick-start and just get to the code, go to <a target="_blank" href="https://github.com/joshuanwankwo/mode_testnet">this repository</a> and follow the readme guide to run it. We will walk you through the code in this tutorial.</div>
</div>

<h3 id="heading-prerequisites">Prerequisites</h3>
<ul>
<li><p>Add MODE Testnet to your metamask using the network info from here:<a target="_blank" href="/o/R2FZT8tk9N9CpkGLNnc3/s/mOUA87dDndFyiETJjxpf/~/changes/76/mode-testnet/mode-testnet-information">Mode Testnet Information</a></p>
</li>
<li><p>Get test ETH sepolia here: <a target="_blank" href="/o/R2FZT8tk9N9CpkGLNnc3/s/mOUA87dDndFyiETJjxpf/~/changes/76/tools/testnet-faucets">Testnet Faucets</a></p>
</li>
<li><p>Bridge to MODE testnet here: <a target="_blank" href="/o/R2FZT8tk9N9CpkGLNnc3/s/mOUA87dDndFyiETJjxpf/~/changes/76/mode-testnet/bridging-to-mode-testnet">Bridging to Mode Testnet</a></p>
</li>
<li><p>Have <a target="_blank" href="https://docs.npmjs.com/downloading-and-installing-node-js-and-npm">Node and NPM</a> installed on your PC</p>
</li>
<li><p>Have a basic understanding of React.js and how blockchain works (You can still follow along if not ;)</p>
</li>
</ul>
<h2 id="heading-smart-contract-deployment-on-mode">Smart Contract Deployment On Mode</h2>
<p>We've crafted a simple smart contract named BidBoard for this tutorial. The contract allows advertisers to bid for space on an advertising board. The code and deployment details are available on this <a target="_blank" href="https://github.com/joshuanwankwo/mode_testnet">GitHub</a> repository and <a target="_blank" href="https://sepolia.explorer.mode.network/address/0x7215c347458DB86531f3c4Cae1c60c0B93e435Ce">Mode Testnet Explorer</a>. You can also write your own custom smart contract and deploy it to Mode by following <a target="_blank" href="/o/R2FZT8tk9N9CpkGLNnc3/s/mOUA87dDndFyiETJjxpf/~/changes/76/build-on-mode/deploying-a-smart-contract">Deploying a Smart Contract</a>.</p>
<h2 id="heading-getting-started">Getting Started</h2>
<p>Now that we have the prerequisites, the first thing we need to do is to open our terminal, navigate into the folder where you want your project to be, and create a simple react app by running the following command  </p>
<p><code>npx create-react-app bidboard-ui</code></p>
<p>It should create the whole React App for you.</p>
<h2 id="heading-install-etherjs">Install Ether.js</h2>
<p>Ethers.js is a sleek library facilitating the interaction between web applications and blockchain. In the App component, we are using ethers.js to interact with our smart contract and also listen to events being emitted from the smart contract. To install ethers.js, navigate into the project you just created and run the following command:</p>
<p><code>npm install ethers</code></p>
<h2 id="heading-create-main-app-component">Create Main App Component</h2>
<p>You can open up the project in VSCode or any other code editor of your choice and then open the <code>App.js</code> file.</p>
<p>Replace all the code and paste this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React, { useState, useEffect } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"./App.css"</span>;
<span class="hljs-keyword">import</span> { ethers } <span class="hljs-keyword">from</span> <span class="hljs-string">"ethers"</span>;

 <span class="hljs-keyword">return</span> (
   <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"app"</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>hello<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
   <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
 );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> App;
</code></pre>
<p>In this file are importing <code>useState</code> and <code>useEffect</code> which we'll be needing later in this tutorial, we’re also importing <code>ethers</code> to enable us to make a connection to our smart contract.</p>
<p>The next thing we need to do is to declare our contract address and ABI file, there are different ways to get the contract ABI but if you deployed your smart contract using foundry, you can find your ABI by checking the following directory ./out/MyContract.sol/MyContract.json, e.g</p>
<p>On the frontend side of things, we’re going to update our <code>App.js</code> adding these lines:</p>
<pre><code class="lang-javascript"> <span class="hljs-keyword">const</span> contractAddress = <span class="hljs-string">"0x7215c347458DB86531f3c4Cae1c60c0B93e435Ce"</span>;
 <span class="hljs-keyword">const</span> abi = [ ABI <span class="hljs-built_in">JSON</span> CODE ] 

 <span class="hljs-keyword">const</span> [currentAd, setCurrentAd] = useState(<span class="hljs-string">"Hello World!"</span>);
 <span class="hljs-keyword">const</span> [currentBid, setCurrentBid] = useState(<span class="hljs-number">0</span>);
 <span class="hljs-keyword">const</span> [advertiser, setAdvertiser] = useState(<span class="hljs-string">"0x0"</span>);
 <span class="hljs-keyword">const</span> [newAd, setNewAd] = useState(<span class="hljs-string">""</span>);
 <span class="hljs-keyword">const</span> [bidAmount, setBidAmount] = useState(<span class="hljs-string">""</span>);
 <span class="hljs-keyword">const</span> [provider, setProvider] = useState(<span class="hljs-literal">null</span>);
 <span class="hljs-keyword">const</span> [status, setStatus] = useState(<span class="hljs-string">""</span>);
</code></pre>
<p>Your <code>App.js</code> should look like:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React, { useState, useEffect } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"./App.css"</span>;
<span class="hljs-keyword">import</span> { ethers } <span class="hljs-keyword">from</span> <span class="hljs-string">"ethers"</span>;

<span class="hljs-keyword">const</span> contractAddress = <span class="hljs-string">"0x7215c347458DB86531f3c4Cae1c60c0B93e435Ce"</span>;
<span class="hljs-keyword">const</span> abi = [ YOUR ABI <span class="hljs-built_in">JSON</span> CODE HERE ] 

 <span class="hljs-keyword">const</span> [currentAd, setCurrentAd] = useState(<span class="hljs-string">"Hello World!"</span>);
 <span class="hljs-keyword">const</span> [currentBid, setCurrentBid] = useState(<span class="hljs-number">0</span>);
 <span class="hljs-keyword">const</span> [advertiser, setAdvertiser] = useState(<span class="hljs-string">"0x0"</span>);
 <span class="hljs-keyword">const</span> [newAd, setNewAd] = useState(<span class="hljs-string">""</span>);
 <span class="hljs-keyword">const</span> [bidAmount, setBidAmount] = useState(<span class="hljs-string">""</span>);
 <span class="hljs-keyword">const</span> [provider, setProvider] = useState(<span class="hljs-literal">null</span>);
 <span class="hljs-keyword">const</span> [status, setStatus] = useState(<span class="hljs-string">""</span>);

 <span class="hljs-keyword">return</span> (
   <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"app"</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>hello<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
   <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
 );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> App;
</code></pre>
<p>We added the contract address, the abi, and a few states that we will need for our dApp to work. Don't worry about all these React states, they are particular for this app so you don't need to fully understand them. Please remember to paste you ABI in your <code>App.js</code> file.</p>
<blockquote>
<p>Usually we would save the ABI in a different file and then import it but in this case we'll just paste all the ABI JSON in our App.js file.</p>
</blockquote>
<h2 id="heading-set-the-provider">Set the Provider</h2>
<p>As the page loads, we'll set our provider to immediately fetch the current advertisement details from our smart contract, as demonstrated in the code below.</p>
<pre><code class="lang-javascript">useEffect(<span class="hljs-function">() =&gt;</span> {
   <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> <span class="hljs-built_in">window</span> !== <span class="hljs-string">"undefined"</span>) {
     <span class="hljs-keyword">if</span> (<span class="hljs-built_in">window</span>.ethereum) {
       setProvider(<span class="hljs-keyword">new</span> ethers.BrowserProvider(<span class="hljs-built_in">window</span>.ethereum));
       <span class="hljs-comment">// getCurrentAd()</span>
     } <span class="hljs-keyword">else</span> {
       <span class="hljs-built_in">console</span>.error(<span class="hljs-string">"Please install MetaMask!"</span>);
     }
   }
 }, []);
</code></pre>
<p>This code uses the <code>useEffect</code> hook in React to execute once after the component mounts. If the <code>window</code> object and <code>window.ethereum</code> are defined, it sets a new provider using <code>ethers.BrowserProvider</code> to interact with the Ethereum blockchain. If <code>window.ethereum</code> is not defined, it logs an error asking to install MetaMask, a browser extension for managing blockchain transactions.</p>
<h2 id="heading-fetch-current-advertisement-data">Fetch Current Advertisement Data</h2>
<p>Create a function to fetch the current advertisement data from our contract and call this function inside a <code>useEffect</code> hook.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fetchCurrentAd</span>(<span class="hljs-params"></span>) </span>{
   <span class="hljs-keyword">try</span> {
       <span class="hljs-comment">// Get the provider, instantiate the contract and then call getCurrentAd</span>
       <span class="hljs-keyword">const</span> provider = <span class="hljs-keyword">new</span> ethers.BrowserProvider(<span class="hljs-built_in">window</span>.ethereum);
       <span class="hljs-keyword">const</span> contract = <span class="hljs-keyword">new</span> ethers.Contract(contractAddress, abi, provider);
       <span class="hljs-keyword">const</span> adData = <span class="hljs-keyword">await</span> contract.getCurrentAd();

       setCurrentAd(adData[<span class="hljs-number">0</span>]);
       setAdvertiser(adData[<span class="hljs-number">1</span>]);
       setCurrentBid(ethers.formatEther(adData[<span class="hljs-number">2</span>]));
       <span class="hljs-built_in">console</span>.log(adData[<span class="hljs-number">0</span>]);
   } <span class="hljs-keyword">catch</span> (error) {
     <span class="hljs-built_in">console</span>.error(<span class="hljs-string">'Error fetching current ad:'</span>, error);
   }
 }

 useEffect(<span class="hljs-function">() =&gt;</span> {
   fetchCurrentAd();
 }, []);
</code></pre>
<p>In the above code, we’re fetching the current ad by setting our provider as we did before, creating a new instance of our contract by passing in the contract address, contractABI, our provider, and then invoking the <code>getCurrentAd</code> function from our smart contract which returns the current adData. Then we pass the adData into our app state so we can render them in the frontend.</p>
<h2 id="heading-update-our-smart-contract-state">Update Our Smart Contract State</h2>
<p>Now we’re able to fetch the current state of our contract we also need to be able to update the state and that’s what the below function does</p>
<pre><code class="lang-javascript"> <span class="hljs-keyword">const</span> submitBid = <span class="hljs-keyword">async</span> () =&gt; {

   <span class="hljs-keyword">const</span> contract = <span class="hljs-keyword">new</span> ethers.Contract(contractAddress, abi, provider); <span class="hljs-comment">// Instantiate the contract</span>
   <span class="hljs-keyword">const</span> signer = provider.getSigner(); <span class="hljs-comment">// Assumes Metamask or similar is injected in the browser</span>
   <span class="hljs-keyword">const</span> contractWithSigner = contract.connect(<span class="hljs-keyword">await</span> signer);

   <span class="hljs-keyword">try</span> {
     <span class="hljs-keyword">const</span> tx = <span class="hljs-keyword">await</span> contractWithSigner.updateMessage(newAd, {
       <span class="hljs-attr">value</span>: ethers.parseEther(bidAmount),
     });
     setStatus(<span class="hljs-string">"Transaction sent, waiting for confirmation..."</span>);
     <span class="hljs-keyword">await</span> tx.wait();
     setStatus(<span class="hljs-string">"Transaction confirmed!"</span>);
   } <span class="hljs-keyword">catch</span> (err) {
     <span class="hljs-built_in">console</span>.error(err);
     setStatus(<span class="hljs-string">"Error: "</span> + err.message);
   }
 };
</code></pre>
<p>In summary, the <code>submitBid</code> function allows users to submit a new bid to the smart contract. It initializes a contract instance and a signer, creates a transaction to update the advertisement message with the new bid, and waits for the transaction to be confirmed on the blockchain.</p>
<p>If any errors occur during this process, they are caught and logged, and the user is informed about the error through a status message.</p>
<h2 id="heading-detailed-explanation-of-the-submitbid-function">Detailed explanation of the submitBid function</h2>
<p><strong>Contract and Signer Initialization</strong></p>
<ul>
<li><p>A new contract instance is created using the ethers.Contract constructor with the provided contract address, ABI, and provider.</p>
</li>
<li><p>A signer, which is essential for authorizing transactions, is obtained from the provider.</p>
</li>
<li><p>The contract instance is then connected with the signer to authorize interactions.</p>
</li>
</ul>
<p><strong>Transaction Creation and Sending:</strong></p>
<ul>
<li><p>A new contract instance is created using the ethers.Contract constructor with the provided contract address, ABI, and provider.</p>
</li>
<li><p>A signer, which is essential for authorizing transactions, is obtained from the provider.</p>
</li>
<li><p>The contract instance is then connected with the signer to authorize interactions.</p>
</li>
</ul>
<p><strong>Transaction Confirmation:</strong></p>
<ul>
<li><p>The await tx.wait(); line waits for the transaction to be confirmed on the blockchain.</p>
</li>
<li><p>Once confirmed, a status message is updated to inform the user of the successful transaction.</p>
</li>
</ul>
<p><strong>Error Handling:</strong></p>
<ul>
<li>If an error occurs at any point in the process, it's caught, logged to the console, and a status message is set to inform the user about the error.</li>
</ul>
<p>The function leverages async/await syntax to handle the asynchronous operations of sending and waiting for the transaction confirmation in a readable manner.</p>
<h2 id="heading-listening-to-events-on-our-smart-contract">Listening to events on our Smart Contract</h2>
<p>Consider you're bidding for ad space, and someone else places a higher bid. It's essential to know about this new bid immediately. This is where event listening helps: it can notify you about the latest bid in real-time, keeping you updated on the bidding activity.</p>
<p>The following code sets up an event listener:</p>
<pre><code class="lang-javascript">useEffect(<span class="hljs-function">() =&gt;</span> {
   <span class="hljs-keyword">const</span> setupEventListener = <span class="hljs-keyword">async</span> () =&gt; {
     <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> <span class="hljs-built_in">window</span>.ethereum !== <span class="hljs-string">"undefined"</span>) {
       <span class="hljs-keyword">const</span> provider = <span class="hljs-keyword">new</span> ethers.BrowserProvider(<span class="hljs-built_in">window</span>.ethereum);
       <span class="hljs-keyword">const</span> contract = <span class="hljs-keyword">new</span> ethers.Contract(contractAddress, abi, provider);
       contract.on(
         <span class="hljs-string">"MessageUpdated"</span>,
         <span class="hljs-function">(<span class="hljs-params">newMessage, newAdvertiser, newAmount, event</span>) =&gt;</span> {
           <span class="hljs-comment">// Update your state variables here</span>
           setCurrentAd(newMessage);
           setCurrentBid(ethers.formatEther(newAmount));
           setAdvertiser(newAdvertiser);
         }
       );
       <span class="hljs-comment">// contract.getEvent</span>
       <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Provider:"</span>, provider); <span class="hljs-comment">// Debug line</span>
     } <span class="hljs-keyword">else</span> {
       <span class="hljs-built_in">console</span>.error(<span class="hljs-string">"Ethereum provider is not available"</span>);
     }
   };

   setupEventListener();

   <span class="hljs-comment">// Cleanup the event listener</span>
   <span class="hljs-keyword">return</span> <span class="hljs-function">() =&gt;</span> {
     <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> <span class="hljs-built_in">window</span>.ethereum !== <span class="hljs-string">"undefined"</span>) {
       <span class="hljs-keyword">const</span> provider = <span class="hljs-keyword">new</span> ethers.BrowserProvider(<span class="hljs-built_in">window</span>.ethereum);
       <span class="hljs-keyword">const</span> contract = <span class="hljs-keyword">new</span> ethers.Contract(contractAddress, abi, provider);
       contract.removeAllListeners(<span class="hljs-string">"MessageUpdated"</span>);
     }
   };
 }, []);
</code></pre>
<p>This above code sets up an event listener using the useEffect hook to listen for the <code>MessageUpdated</code> event emitted by the smart contract whenever the advertisement message is updated.</p>
<p>When such an event is detected, it updates the state variables <code>currentAd</code>, <code>currentBid</code>, and <code>advertiser</code> with the new message, advertiser, and bid amount, respectively. This ensures that the displayed data on the web app remains synchronized with the blockchain.</p>
<p>Lastly, it provides a cleanup function to remove the event listener, preventing potential memory leaks when the component is unmounted or re-rendered.</p>
<h2 id="heading-code-the-ui">Code The UI</h2>
<p>That’s it, we’re done with the on-chain functionalities, now let’s build UIs to test them out. How you choose to build your UI is entirely up to you, for our project, we’re just going to add the following JSX to our <code>App.js</code> code:</p>
<pre><code class="lang-javascript">&lt;div className=<span class="hljs-string">"app"</span>&gt;
     {<span class="hljs-comment">/* Landing Section */</span>}
     &lt;section className=<span class="hljs-string">"landing"</span>&gt;
       <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>BidBoard<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span></span>
       <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Status: {status}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span></span>
     &lt;/section&gt;

     <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"container"</span>&gt;</span>
       {/* Bid Section */}
       <span class="hljs-tag">&lt;<span class="hljs-name">section</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"bid-section"</span>&gt;</span>
         <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
           <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span>
           <span class="hljs-attr">value</span>=<span class="hljs-string">{newAd}</span>
           <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setNewAd(e.target.value)}
           placeholder="Enter your advert message"
         /&gt;
         <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
           <span class="hljs-attr">type</span>=<span class="hljs-string">"number"</span>
           <span class="hljs-attr">value</span>=<span class="hljs-string">{bidAmount}</span>
           <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setBidAmount(e.target.value)}
           placeholder="Enter your bid amount"
         /&gt;
         <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{submitBid}</span>&gt;</span>Submit Bid<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
       <span class="hljs-tag">&lt;/<span class="hljs-name">section</span>&gt;</span>

       {/* Advert Display Section */}
       <span class="hljs-tag">&lt;<span class="hljs-name">section</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"advert-display"</span>&gt;</span>
         <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"current-ad"</span>&gt;</span>"{currentAd}"<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
         <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"card-details"</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"current-bid"</span>&gt;</span>
             Current Bid: <span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
             {currentBid} ETH
           <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"advertiser"</span>&gt;</span>
             Advertiser: <span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
             {advertiser}
           <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
         <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
       <span class="hljs-tag">&lt;/<span class="hljs-name">section</span>&gt;</span>
     <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>

     {<span class="hljs-comment">/* Footer Section */</span>}
     &lt;footer&gt;
       <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">a</span>
         <span class="hljs-attr">href</span>=<span class="hljs-string">"https://github.com/your-repo"</span>
         <span class="hljs-attr">target</span>=<span class="hljs-string">"_blank"</span>
         <span class="hljs-attr">rel</span>=<span class="hljs-string">"noopener noreferrer"</span>
       &gt;</span>
         GitHub Repository
       <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span></span>
       {<span class="hljs-comment">/* Add more links as needed */</span>}
     &lt;/footer&gt;
   &lt;/div&gt;
</code></pre>
<h2 id="heading-running-the-project">Running the project</h2>
<p>To run the project open your terminal and run the following command in the project's folder:</p>
<p><code>Npm start</code></p>
<p>Your console should look similar to this:</p>
<p><img src="https://lh4.googleusercontent.com/iXPtWgKwS3obTjdvUF_-b88QcBshtDTx66Y2Ayn4ArngJdhehjleB4JQqzuuf0NKuWj0v4p5TPdYvmA674kurL_3VAAx93d903LFiFtdMbACORLUfhL65YFHo9VOzlbz3Ma7QZOvVtTw6oNmSya_SqE" alt /></p>
<p>Open the URL shown in your browser and you are good to try your dApp!</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>This tutorial provided a hands-on journey through creating a web application and connecting it to a smart contract deployed on Mode Testnet using ether.js.</p>
<p>Through this project, we delved into essential steps from setting up the development environment to real-time tracking of smart contract events. You can clone the <a target="_blank" href="https://github.com/joshuanwankwo/mode_testnet">code</a> and play around with it!</p>
<p>To learn more about Mode and how to turn your code into a business, join our <a target="_blank" href="https://discord.gg/modenetworkofficial">Discord</a> and say hello 👋</p>
]]></content:encoded></item></channel></rss>