<?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[Joshua "koha" Omobola]]></title><description><![CDATA[Web3. Product Design. DevRel]]></description><link>https://koha.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1660052999886/bFpo4Xenl.png</url><title>Joshua &quot;koha&quot; Omobola</title><link>https://koha.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 09:45:08 GMT</lastBuildDate><atom:link href="https://koha.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to monetize digital content with x402-Solana-React and Nextjs]]></title><description><![CDATA[The x402 protocol is an open standard for HTTP 402 payment-required responses, allowing developers to monetize resources directly through the web. It…]]></description><link>https://koha.hashnode.dev/monetize-content-with-x402-solana-react-and-nextjs</link><guid isPermaLink="true">https://koha.hashnode.dev/monetize-content-with-x402-solana-react-and-nextjs</guid><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Mon, 16 Mar 2026 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/621cef63c07e2ceec785f88b/ce6e93ef-ce01-4ccc-b4e6-c5de249e2ea9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The <strong>x402</strong> protocol is an open standard for <a href="https://docs.payai.network/x402/introduction">HTTP 402 payment-required responses</a>, allowing developers to monetize resources directly through the web. It enables you to gate access to premium digital goods such as AI agent services or paid API endpoints requiring a crypto payment to unlock them.</p>
<p><a href="https://docs.payai.network/x402/quickstart">Building with x402 today from scratch</a>, however, means you would need to manually handle wallet connections, and even build your own paywall UI. <strong>x402-solana-react</strong> removes that overhead. It’s a React library by <a href="https://payai.network">PayAI</a> that provides drop-in React components and hooks that handle the heavy lifting of wallet interactions and transaction signing so you can ship your monetized application significantly faster. If you want to go deep on how it works, <a href="https://payai.network/">PayAI’s</a> <a href="https://docs.payai.network/x402/introduction">x402 introduction</a> is the best starting point</p>
<p>In this tutorial, you will build a x402 monetized Next.js application using components provided by x402-solana-react. By the end, you'll have a working app that accepts USDC payments to unlock premium content.</p>
<p><strong>Prerequisites</strong> To follow along with this guide, you will need:</p>
<ul>
<li><p>Node.js v22 or higher installed on your local machine</p>
</li>
<li><p>Basic familiarity with React and Next.js</p>
</li>
<li><p>A Solana wallet browser extension, such as Phantom or Solflare.</p>
</li>
<li><p>DevNet SOL and USDC tokens for testing.</p>
<ul>
<li><p>You can request SOL from the <a href="https://faucet.solana.com/">Solana Faucet</a>.</p>
</li>
<li><p>You can request USDC from the <a href="https://faucet.circle.com/">Circle Faucet</a> (select <strong>Solana Devnet</strong>).</p>
</li>
</ul>
</li>
</ul>
<hr />
<h2>Step 1 — Setting up the project</h2>
<p>First, we need to create a new Next.js app and install the necessary libraries to handle the x402 payment flow. Open your terminal and run the following command:</p>
<pre><code class="language-plaintext">npx create-next-app@latest x402-premium-app
</code></pre>
<p>The installation will prompt you to select a few options; make sure to accept all the defaults</p>
<p>Change to the <code>x402-premium-app</code> directory:</p>
<pre><code class="language-plaintext">cd x402-premium-app
</code></pre>
<p>Now, install the <strong>x402-solana-react</strong> library, the <strong>x402-solana</strong> SDK, and the standard Solana wallet adapters:</p>
<pre><code class="language-plaintext">npm install @payai/x402-solana-react @solana/wallet-adapter-react @solana/wallet-adapter-react-ui @solana/wallet-adapter-wallets @solana/web3.js
</code></pre>
<p>Finally, to ensure the wallet and paywall components render correctly, you must import the necessary CSS styles globally. Open the <code>app/layout.tsx</code> file and add the following imports:</p>
<pre><code class="language-plaintext">import "@payai/x402-solana-react/styles";
import "@solana/wallet-adapter-react-ui/styles.css";
</code></pre>
<p>With the project configured and dependencies installed, you are now ready to build the application interface.</p>
<hr />
<h2>Step 2 — <strong>Creating the Monetized Content Page</strong></h2>
<p>In this step, you will replace the default Next.js template with your monetized content. Then wrap a sample premium content with the <code>X402Paywall</code> component, which will handle the payment flow automatically.</p>
<p>Open <code>app/page.tsx</code> and replace its entire contents with the following code:</p>
<pre><code class="language-plaintext">"use client";
import { X402Paywall } from "@payai/x402-solana-react";

export default function Home() {
  return (
    &lt;X402Paywall
      amount={0.1}
      description="The Solana x402 Paywall Content"
      network="solana-devnet" 
      apiEndpoint="http://localhost:3000/api/paid"
      showBalance={true}
      showNetworkInfo={true}
      showPaymentDetails={true}
      onPaymentSuccess={(txId) =&gt; console.log("Payment successful!", txId)}
      onPaymentStart={() =&gt; console.log("Payment started!")}
      onPaymentError={(error) =&gt; console.log("Payment error!", error)}
      onDisconnect={() =&gt; console.log("User disconnected!")}
      theme="dark"
    &gt;
      &lt;div className="flex min-h-screen items-center justify-center flex-col text-black text-2xl font-bold bg-zinc-50 font-sans dark:bg-black"&gt;
        &lt;div&gt;The Premium Content&lt;/div&gt;
        &lt;div&gt;
          &lt;iframe
            width="560"
            height="315"
            src="https://www.youtube.com/embed/9nr5gwMn6cg?si=Y7Os_v_Ol8aesTGW"
            title="YouTube video player"
            allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
            referrerPolicy="strict-origin-when-cross-origin"
            allowFullScreen
          &gt;&lt;/iframe&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/X402Paywall&gt;
  );
}
</code></pre>
<p>The code above does the following:</p>
<ul>
<li><p>Wraps the premium content within the <code>X402Paywall</code> component, ensuring the children elements are only rendered after a successful on-chain transaction.</p>
</li>
<li><p>Uses the <code>amount</code> prop to specify the cost in USDC (0.1 USDC) and the <code>network</code> prop to ensure the wallet connects to <code>solana-devnet</code>.</p>
</li>
<li><p>Uses the <code>apiEndpoint</code> prop to direct the component to your custom <code>/api/paid</code> route for x402 payment flow and verification.</p>
</li>
<li><p>It uses <code>onPaymentSuccess</code> callback to log the transaction signature, which you can use to trigger additional client-side events like analytics tracking or confetti effects.</p>
<img src="https://paper-attachments.dropboxusercontent.com/s_821D4BB9769CCCA1B502CAC22B53A8B684CDBCC6D8D1C776C161434A22A08DF0_1766161974424_image.png" alt="" style="display:block;margin:0 auto" /></li>
</ul>
<hr />
<h2>Step 3 — Creating the API Endpoint</h2>
<p>Inside <code>app/api/paid</code> directory, create a new file named <code>route.ts</code>.</p>
<pre><code class="language-plaintext">mkdir -p app/api/paid
touch app/api/paid/route.ts
</code></pre>
<p>Your file structure should look like this:</p>
<pre><code class="language-plaintext">app/
├── api/
│   └── paid/
│       └── route.ts
...
</code></pre>
<img src="https://paper-attachments.dropboxusercontent.com/s_821D4BB9769CCCA1B502CAC22B53A8B684CDBCC6D8D1C776C161434A22A08DF0_1766162092282_image.png" alt="" style="display:block;margin:0 auto" />

<p>Add the following code to <code>route.ts</code>.</p>
<pre><code class="language-plaintext">// app/api/paid/route.ts

import { NextRequest, NextResponse } from "next/server";
import { X402PaymentHandler } from "x402-solana/server";

const x402 = new X402PaymentHandler({
  network: "solana-devnet",
  treasuryAddress: process.env.TREASURY_WALLET_ADDRESS!,
  facilitatorUrl: "https://facilitator.payai.network",
});

export async function POST(req: NextRequest) {
  // 1. Extract payment header
  const paymentHeader = x402.extractPayment(req.headers);
  const body = await req.json().catch(() =&gt; ({}));

  // Default to 2.5 USDC if no amount is provided in body
  const requestAmount = body.amount || 0.1; 

  // 2. Create payment requirements
  const paymentRequirements = await x402.createPaymentRequirements({
    price: {
      amount: (requestAmount * 1000000).toString(), // (amount in micro-units)
      asset: {
        address: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", // USDC devnet mint
        decimals: 6,
      },
    },
    network: "solana-devnet",
    config: {
      description: "Demo for x402-solana-react by PayAI",
      resource: `http://localhost:3000/api/paid`,
    },
  });

  if (!paymentHeader) {
    // Return 402 with payment requirements if no payment is found
    const response = x402.create402Response(paymentRequirements);
    return NextResponse.json(response.body, { status: response.status });
  }

  // 3. Verify payment
  const verified = await x402.verifyPayment(paymentHeader, paymentRequirements);
  if (!verified) {
    return NextResponse.json({ error: "Invalid payment" }, { status: 402 });
  }

  // 4. Settle payment
  await x402.settlePayment(paymentHeader, paymentRequirements);

  // 5. Return response
  return NextResponse.json({
    success: true,
    message: "Payment received",
    content: "Premium content here",
  });
}
</code></pre>
<p>The code above initialises a payment handler that listens for requests. If a request comes in without a payment, it returns a <strong>402 Payment Required</strong> status.</p>
<p>The <code>x402.extractPayment(req.headers)</code> method looks for the <code>X-Payment</code> header in the incoming request. This header contains the transaction signature (proof of payment) sent by the frontend.</p>
<p>We manually calculate the expected amount in micro-units. Since USDC has 6 decimals, <code>0.10</code> USDC becomes <code>100,000</code> micro-units. This ensures we verify that the user paid the <em>exact</em> correct amount to the correct address.</p>
<p>The <code>verifyPayment</code> function checks the Solana blockchain to confirm that the transaction in the header actually occurred, was successful, and transferred the required funds to your treasury wallet.</p>
<p>Finally, <code>settlePayment</code> marks the transaction as processed via <a href="https://facilitator.payai.network/">PayAI Facilitator</a>, preventing replay attacks where a user might try to use the same payment proof twice. Once the frontend pays and retries the request with a proof of payment, the handler verifies it on-chain and returns the content.</p>
<p>For this to work, you need to tell the handler where to send the funds. Create a <code>.env.local</code> file in your project root and add your wallet address:</p>
<pre><code class="language-plaintext">TREASURY_WALLET_ADDRESS=Your_Solana_Wallet_Address_Here
</code></pre>
<h2>Step 4 — Testing the Application</h2>
<p>Start the development server by running the following command:</p>
<pre><code class="language-plaintext">npm run dev
</code></pre>
<p>Open <code>http://localhost:3000</code> in your browser, and you should see the <strong>Paywall</strong> UI from <code>x402-Solana-React</code> blocking the content.</p>
<p>When users click the unlock button, the Phantom or Solflare wallet pops up, prompting them to confirm the payment.</p>
<p>After the payment succeeds, the content is unlocked and becomes visible to the user.</p>
<img src="https://paper-attachments.dropboxusercontent.com/s_821D4BB9769CCCA1B502CAC22B53A8B684CDBCC6D8D1C776C161434A22A08DF0_1767925001030_image.png" alt="Unlocked premium content after successful payment" style="display:block;margin:0 auto" />

<p>The GIF below demonstrates the entire flow - from the locked paywall, to payment confirmation, to the unlocked premium content.</p>
<img src="https://paper-attachments.dropboxusercontent.com/s_821D4BB9769CCCA1B502CAC22B53A8B684CDBCC6D8D1C776C161434A22A08DF0_1766162705702_Screen+Recording+2025-12-19+at+17.37.13.gif" alt="Full payment flow: user clicks unlock → confirms in wallet → premium content becomes available." style="display:block;margin:0 auto" />

<h2>Conclusion</h2>
<p>In this tutorial, you integrated the x402 protocol into a Next.js application using <code>x402-solana-react</code>. You set up a client-side paywall component and API to securely monetize your content with USDC.</p>
<p>Here's a list of resources I'd recommend you check out about x402 and x402-solana-react:</p>
<ul>
<li><p><a href="https://x402.payai.network/">An Interactive x402 Demo</a> built by PayAI</p>
</li>
<li><p>The <a href="https://github.com/kohasummons/x402-prompt-store/tree/starter-template">Github Repo</a> for this tutorial</p>
</li>
<li><p>The Official <a href="https://github.com/PayAINetwork/x402-solana-react">x402-solana-react documentation</a></p>
</li>
<li><p><a href="https://koha.hashnode.dev/x402-explain-like-im-five">x402, explained like</a> <a href="https://koha.hashnode.dev/x402-explain-like-im-five">I’m five</a></p>
</li>
</ul>
<p>If you are stuck or have questions, find me on Twitter (<a href="https://x.com/kohawithstuff">@kohawithstuff</a>) or tag me in the <a href="https://discord.com/invite/eWJRwMpebQ">PayAI Community</a>. I'm always ready to help.</p>
]]></content:encoded></item><item><title><![CDATA[How to Monetise Your API in Next.js using the x402 Protocol]]></title><description><![CDATA[What if you could charge a few cents every time users access your API? This is almost impossible using payment processors like Stripe and PayPal. Their…]]></description><link>https://koha.hashnode.dev/how-to-monetise-your-api-in-nextjs-using-the-x402-protocol</link><guid isPermaLink="true">https://koha.hashnode.dev/how-to-monetise-your-api-in-nextjs-using-the-x402-protocol</guid><category><![CDATA[AI]]></category><category><![CDATA[agents]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[x402]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Wed, 12 Nov 2025 08:10:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1762482863660/ccff250b-6802-418c-9e92-a83b7e0da5fb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>What if you could charge a few cents every time users access your API? This is almost impossible using payment processors like Stripe and PayPal. Their transaction fees alone make micropayments impossible, not to mention the complex setup needed to get it to work.  Plus, you can't ask users to fill in a payment form just to spend half a cent on an API call every time. Nobody is going to do that.</p>
<p><strong>x402</strong> changes this.</p>
<blockquote>
<p><em>x402 is a new payment standard that lets you charge for API access through standard HTTP responses. x402 works without credit cards, sign-ups, or subscriptions. It uses</em> <a target="_blank" href="https://stripe.com/en-nl/resources/more/what-is-a-stablecoin"><em>stablecoins</em></a> <em>on the blockchain to make instant and near-zero fees finally possible.</em></p>
</blockquote>
<p>In this tutorial, you'll build a simple marketplace for premium AI prompts with Next.js. Users will be able to unlock premium AI prompts by paying <em>$0.005 USD</em> per call to your API. </p>
<p>Here’s a <a target="_blank" href="https://x402-prompt-store-git-starter-template-joshua-omobolas-projects.vercel.app/">demo</a> of what you will build using this guide:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1762842484273/02e3d762-53b4-408f-9986-7430bd127421.gif" alt="an image showing the final demo" class="image--center mx-auto" /></p>
<blockquote>
<p><em>Prefer a video version of this tutorial? Check out</em> <a target="_blank" href="https://youtu.be/zMh6CH7tWhE"><em>How to Monetise your APIs in Next.js with x402 Protocol</em></a></p>
</blockquote>
<h2 id="heading-what-is-x402">What is x402?</h2>
<p><a target="_blank" href="https://x402.org">x402</a> is an open payment standard that enables web services and AI agents to charge for API access and content directly over HTTP. It is built on top of the long-reserved <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/402">HTTP 402</a> ”<a target="_blank" href="https://x402.gitbook.io/x402/core-concepts/http-402?q=">Payment Required</a>” status code. </p>
<p>x402 removes the need for API keys, subscriptions, and manual payment processing, enabling any web service to request payment in real time using <a target="_blank" href="https://stripe.com/en-nl/resources/more/what-is-a-stablecoin">stablecoins</a> like USDC. With just one line of code, developers can integrate pay-per-use monetisation and receive instant, seamless payments for APIs &amp; digital services.</p>
<p><strong>Core Components of x402</strong></p>
<ul>
<li><p><strong>Sellers</strong>: People or companies who want to monetise their APIs or content.</p>
</li>
<li><p><strong>Buyers</strong>: Developers and AI agents seeking to access paid services without accounts or manual payment flows.</p>
</li>
<li><p><strong>Facilitators</strong>: This is a service that verifies and settles payments on behalf of the buyers and sellers. e.g <a target="_blank" href="https://payai.network">PayAI</a></p>
</li>
</ul>
<p><strong>How x402 Works</strong></p>
<p>When a <code>client</code>(user) first requests a resource from the  server(your app), the server responds with an <code>HTTP 402</code> <code>Payment Required</code> status code along with payment instructions. </p>
<p>The client then prepares the payment based on these requirements and retries the request, this time including an <code>X-PAYMENT</code> header containing a signed payload. </p>
<p>On receiving this payment proof, the server verifies it through a <code>facilitator</code> service, settles the payment on the blockchain, and finally delivers the requested resource once the payment is confirmed.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1762842549701/a162ac1d-4de8-4fc4-ab47-7aabda80c552.png" alt="an image showing the payment flow of how x402 works" class="image--center mx-auto" /></p>
<p>Now that you have a good understanding of x402 protocol and how it works under the hood, let's move on to building the demo. </p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>To follow along with this guide, you will need:</p>
<ul>
<li><p>Node.js 22+ installed</p>
</li>
<li><p>Basic knowledge of Next.js fundamentals</p>
</li>
<li><p><a target="_blank" href="https://metamask.io">MetaMask wallet</a> Chrome extension installed in your browser. You will also need to <a target="_blank" href="https://getblock.io/blog/add-base-sepolia-testnet-metamask/">add the base sepolia network</a> and <a target="_blank" href="https://faucet.circle.com/">claim some free USDC testnet tokens</a> from the faucet.</p>
</li>
</ul>
<h2 id="heading-step-1-setting-up-the-project">Step 1: Setting up the project</h2>
<p>First, create a new Next.js app by running the following command in your terminal:</p>
<pre><code class="lang-bash">npx create-next-app@latest x402-prompt-store
</code></pre>
<p>The installation will prompt you to select a few options; make sure to accept all the defaults</p>
<p>Next, navigate into the <code>x402-prompt-store</code> directory, and install the dependencies:</p>
<pre><code class="lang-bash">// navigate into project
<span class="hljs-built_in">cd</span> x402-prompt-store

// install the packages you need
npm install x402-next x402-fetch viem
</code></pre>
<p>Here's what each one does:</p>
<ul>
<li><p><strong>x402-next</strong> — middleware package for Next.js that intercepts API requests and verifies payments</p>
</li>
<li><p><strong>x402-fetch</strong> — client library that automatically handles the payment flow when it sees a 402 status code response</p>
</li>
<li><p><strong>viem</strong> — a library that handles blockchain interactions like connecting to wallets &amp; signing transactions.</p>
</li>
</ul>
<h2 id="heading-step-2-creating-the-api-routes">Step 2: Creating the API routes</h2>
<p>Inside of <code>app/api/premium</code> directory, create a new file named <code>route.ts</code></p>
<pre><code class="lang-bash">touch app/api/premium/route.ts
</code></pre>
<p>Your file structure should look like this:</p>
<pre><code class="lang-bash"> app/
  ├── api/
  │   └── premium/
  │       └── route.ts
  ...
</code></pre>
<p>Add the following code to <code>route.ts</code>:</p>
<pre><code class="lang-bash">// app/api/premium/route.ts

import { NextRequest } from <span class="hljs-string">"next/server"</span>;
const PREMIUM_PROMPT = `You are a creative developer who creates stunning UI with motion and interactions. You create eye stunning ui experience with Lovable <span class="hljs-keyword">for</span> Anvil. You are given a prompt and you need to create a lovable UI prompt <span class="hljs-keyword">for</span> Anvil.`;

<span class="hljs-built_in">export</span> async <span class="hljs-keyword">function</span> GET(req: NextRequest) {
  <span class="hljs-built_in">return</span> Response.json({ promptText: PREMIUM_PROMPT });
}
</code></pre>
<p>The code above returns the <code>PREMIUM_PROMPT</code> as JSON when it’s called.</p>
<p>You now have a working API endpoint. Start your dev server with <code>npm run dev</code> and visit <code>http://localhost:3000/api/premium</code> in your browser. The output should be the JSON response of the prompt.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1762842591038/3c0bd4e9-d029-4b47-9c00-52ec040f398f.gif" alt="an image showing the api response from the x402 demo without payment middleware" class="image--center mx-auto" /></p>
<p>Right now, this endpoint is completely free and accessible to anyone. In the next step, you'll add a payment middleware to protect it behind a paywall.</p>
<h2 id="heading-step-3-adding-a-payment-paywall-to-the-api">Step 3: Adding a payment paywall to the API</h2>
<p>Create <code>middleware.ts</code> at the root of your project, where you will define the payment guard for the API endpoint.</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// middleware.ts</span>
<span class="hljs-keyword">import</span> { paymentMiddleware } <span class="hljs-keyword">from</span> <span class="hljs-string">'x402-next'</span>;

<span class="hljs-keyword">const</span> SellersWallet = <span class="hljs-string">"Replace_with_your_wallet_address"</span>
<span class="hljs-keyword">const</span> facilitatorObj = { 
    url: <span class="hljs-string">"https://facilitator.payai.network"</span> <span class="hljs-keyword">as</span> <span class="hljs-string">`https://<span class="hljs-subst">${<span class="hljs-built_in">string</span>}</span>`</span> 
}

<span class="hljs-comment">// middleware configuration that paywalls the /api/premium route</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> middleware = paymentMiddleware(
  SellersWallet,
  {
    <span class="hljs-string">'/api/premium'</span>: { 
      price: <span class="hljs-string">'$0.005'</span>,
      network: <span class="hljs-string">"base-sepolia"</span>,
      config: {
        description: <span class="hljs-string">'Access to protected premium content'</span>
      }
    },
  },
  facilitatorObj
);

<span class="hljs-comment">// Configure which paths the middleware should run on</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> config = {
  matcher: [
    <span class="hljs-string">'/api/:path*'</span>,
  ],
  runtime: <span class="hljs-string">"nodejs"</span>
};
</code></pre>
<p>Let's break this down:</p>
<p>The code above uses the <code>paymentMiddleware</code> function from <code>x402-next</code> to define the monetised routes. It accepts three parameters:</p>
<ul>
<li><p><strong><em>payTo</em></strong>: The wallet address to receive the payments. R<em>eplace</em> <code>SellersWallet</code> with your own wallet address.</p>
</li>
<li><p><strong><em>routes</em></strong>: Route configurations for the protected endpoints</p>
</li>
<li><p><strong><em>facilitator</em></strong>: Configuration for the facilitator service that verifies the payments</p>
</li>
</ul>
<p>With these three parameters, you can pretty much configure the monetisation settings for any API in the app.</p>
<p>In this case, every call to <code>api/premium</code> will cost <code>$0.005 USD</code>, and the payment will settle to the <code>SellersWallet</code> on the <code>base-sepolia</code> network.</p>
<p>The <strong>matcher</strong> config tells Next.js which routes this middleware should run on, in this case, any route under <code>/api/</code> directory.</p>
<p>Now, when someone requests <code>/api/premium</code>, the middleware returns a 402 status code response with payment details (how much, where to send it, and which blockchain network).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1762842622629/31d1cc3a-8958-4cdf-8e15-c7af440eeeee.png" alt="an image showing the x402 status code after adding the payment middleware" class="image--center mx-auto" /></p>
<h2 id="heading-step-4-creating-the-frontend-interface">Step 4: Creating the Frontend Interface</h2>
<p>Now that you have the API endpoint and paywall middleware in place, let’s add the frontend UI.</p>
<p>Replace the content of  <code>app/page.tsx</code> with the following code:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// app/page.tsx</span>

<span class="hljs-string">"use client"</span>;

<span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> { wrapFetchWithPayment } <span class="hljs-keyword">from</span> <span class="hljs-string">"x402-fetch"</span>;
<span class="hljs-keyword">import</span> { createWalletClient, custom } <span class="hljs-keyword">from</span> <span class="hljs-string">"viem"</span>;
<span class="hljs-keyword">import</span> { baseSepolia } <span class="hljs-keyword">from</span> <span class="hljs-string">"viem/chains"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> [loading, setLoading] = useState(<span class="hljs-literal">false</span>);

  <span class="hljs-keyword">const</span> handlePremiumPromptClick = <span class="hljs-keyword">async</span> () =&gt; {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Premium prompt clicked"</span>);
  };

  <span class="hljs-keyword">return</span> (
      &lt;main className=<span class="hljs-string">"mx-auto max-w-3xl p-6"</span>&gt;
      &lt;h1 className=<span class="hljs-string">"text-2xl font-semibold mb-4 font-mono"</span>&gt;
        THE PROMPT SUPERSTORE
      &lt;/h1&gt;
      &lt;ul className=<span class="hljs-string">"space-y-4"</span>&gt;
        {<span class="hljs-comment">/* Premium */</span>}
        &lt;li className=<span class="hljs-string">"border p-4 rounded-md"</span>&gt;
          &lt;div className=<span class="hljs-string">"mt-2 text-sm"</span>&gt;Premium($<span class="hljs-number">0.005</span>)&lt;/div&gt;
          &lt;h2 className=<span class="hljs-string">"text-xl font-medium"</span>&gt;
            Creating Lovable UI Prompts <span class="hljs-keyword">for</span> Anvil
          &lt;/h2&gt;
          &lt;button
            onClick={handlePremiumPromptClick}
            className=<span class="hljs-string">"cursor-pointer mt-3 inline-block text-xs bg-amber-500 dark:text-black px-2 py-0.5 font-mono"</span>&gt;
            {loading ? <span class="hljs-string">"Unlocking..."</span> : <span class="hljs-string">"Unlock"</span>}
          &lt;/button&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/main&gt;
  );
}
</code></pre>
<p>This code above creates a minimal UI with basic tailwind styling that lets users access your AI prompts.</p>
<p>Right now, you have a single premium prompt card, and clicking the "unlock" button calls the <code>handlePremiumPromptClick</code> function, which prints a message to the console.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1762842661174/ee18101f-7fea-4e63-a3d1-6d1e2358d37b.png" alt="an image showing the frontend ui for the x402 demo" class="image--center mx-auto" /></p>
<p>Now let's implement the payment logic. </p>
<p>Update the <code>handlePremiumPromptClick</code> function with the following code:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// app/page.tsx</span>

<span class="hljs-keyword">const</span> handlePremiumPromptClick = <span class="hljs-keyword">async</span> () =&gt; {
    <span class="hljs-keyword">try</span> {
      setLoading(<span class="hljs-literal">true</span>);

      <span class="hljs-comment">// Request wallet access</span>
      <span class="hljs-keyword">const</span> [address] = <span class="hljs-keyword">await</span> (<span class="hljs-built_in">window</span> <span class="hljs-keyword">as</span> <span class="hljs-built_in">any</span>).ethereum.request({
        method: <span class="hljs-string">"eth_requestAccounts"</span>,
      });

      <span class="hljs-comment">// Create wallet client</span>
      <span class="hljs-keyword">const</span> walletClient = createWalletClient({
        account: address,
        chain: baseSepolia,
        transport: custom((<span class="hljs-built_in">window</span> <span class="hljs-keyword">as</span> <span class="hljs-built_in">any</span>).ethereum),
      });

      <span class="hljs-comment">// Wrap fetch with payment capability</span>
      <span class="hljs-keyword">const</span> fetchWithPayment = wrapFetchWithPayment(
        fetch <span class="hljs-keyword">as</span> <span class="hljs-built_in">any</span>,
        walletClient <span class="hljs-keyword">as</span> <span class="hljs-built_in">any</span>
      );

      <span class="hljs-comment">// Make API request &amp; automatically handle payment on 402</span>
      <span class="hljs-keyword">const</span> res = <span class="hljs-keyword">await</span> fetchWithPayment(<span class="hljs-string">"/api/premium"</span>, {
        method: <span class="hljs-string">"GET"</span>,
        headers: {
          <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>,
        },
      });

      <span class="hljs-keyword">const</span> data = <span class="hljs-keyword">await</span> res.json();
      alert(<span class="hljs-string">`Prompt: <span class="hljs-subst">${data.promptText}</span>`</span>);

    } <span class="hljs-keyword">catch</span> (error) {
      <span class="hljs-built_in">console</span>.error(<span class="hljs-string">"Payment error:"</span>, error);
      alert(<span class="hljs-string">"Failed to unlock premium prompt. Please try again."</span>);

    } <span class="hljs-keyword">finally</span> { 
      setLoading(<span class="hljs-literal">false</span>);
    }
  };
</code></pre>
<p>The code above does the following:</p>
<ul>
<li><p>Requests the user's wallet address from the browser using the MetaMask wallet extension</p>
</li>
<li><p>Creates a wallet client configured with the <code>baseSepolia</code> testnet</p>
</li>
<li><p>Wraps the native browser <code>fetch</code> with <code>wrapFetchWithPayment()</code> function, which automatically handles payment when receiving a <code>402 response</code></p>
</li>
<li><p>Makes a <code>GET</code> request to <code>/api/premium</code>, when the middleware returns 402, the payment flow executes automatically</p>
</li>
<li><p>Displays the premium prompt in an alert on success, or shows an error message if payment fails</p>
</li>
</ul>
<p>Let's test it out.</p>
<h2 id="heading-step-5-testing-the-paywall">Step 5: Testing the Paywall</h2>
<p>Start the server by running the following command:</p>
<pre><code class="lang-bash">npm run dev
</code></pre>
<p>Open <code>http://localhost:3000</code> in your browser, and you should see <strong>THE PROMPT SUPERSTORE</strong> UI with one premium prompt item card.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1762843093776/27434ea5-9653-4ce7-89a4-152ecc213e25.gif" alt="an image showing the frontend ui for the x402 final demo" class="image--center mx-auto" /></p>
<p>When users click the unlock button, the MetaMask wallet will pop up, prompting them to confirm a <code>$0.005</code> USD payment to access the AI prompt.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>That's it! You just learned how to monetise APIs in Next.js using the x402 Protocol. You built a simple AI prompts store that requires users to pay to call your API. This kind of Micropayment is really difficult to do with traditional payment providers like Stripe and PayPal, but with x402, it's effortless.</p>
<p>For next steps, explore how to deploy to mainnet or <a target="_blank" href="https://github.com/kohasummons/x402-prompt-store">implement dynamic pricing</a> based on content value. Fun stuff!</p>
<p>Here's a list of resources I'd recommend you check out about x402:</p>
<ul>
<li><p><a target="_blank" href="https://github.com/kohasummons/x402-prompt-store/tree/starter-template">Github Repo for this tutorial</a></p>
</li>
<li><p><a target="_blank" href="https://x402.org">The Official x402 documentation</a></p>
</li>
<li><p><a target="_blank" href="https://docs.cdp.coinbase.com/x402">Coinbase x402 Docs</a></p>
</li>
<li><p><a target="_blank" href="https://koha.hashnode.dev/x402-explain-like-im-five">x402, explained like I’m five</a></p>
</li>
</ul>
<p>If you are stuck or have questions, find me on Twitter (<a target="_blank" href="https://x.com/kohawithstuff">@kohawithstuff</a>). I'm always ready to help.</p>
<p>Happy building!</p>
]]></content:encoded></item><item><title><![CDATA[AI benchmarks, explain like i'm five]]></title><link>https://koha.hashnode.dev/ai-benchmarks-explain-like-im-five</link><guid isPermaLink="true">https://koha.hashnode.dev/ai-benchmarks-explain-like-im-five</guid><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Mon, 22 Sep 2025 21:40:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1758577152282/ac273319-3da1-4610-9258-a217c01308e7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758577148751/b93f4fc0-c78a-4024-ad53-1ff23453b6e8.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Agents Payment Protocol, explain like i'm five]]></title><description><![CDATA[Agents Payment Protocol (AP2) is an open, shared protocol that provides a common language for secure, compliant transactions between agents and merchants…]]></description><link>https://koha.hashnode.dev/agents-payment-protocol-explain-like-im-five</link><guid isPermaLink="true">https://koha.hashnode.dev/agents-payment-protocol-explain-like-im-five</guid><category><![CDATA[AI]]></category><category><![CDATA[agents]]></category><category><![CDATA[agentic AI]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Fri, 19 Sep 2025 17:21:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1758302305716/432eb6d6-c029-4221-a58e-c7df83850d3d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Agents Payment Protocol (AP2) is an open, shared protocol that provides a common language for secure, compliant transactions between agents and merchants, helping to prevent a fragmented ecosystem. It also supports different payment types–from credit and debit cards to stable coins and real-time bank transfers</p>
<p>ELI5:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758302329699/791b3ecd-5407-47ab-b5c7-6418aefc191d.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[x402, explain like i'm five]]></title><link>https://koha.hashnode.dev/x402-explain-like-im-five</link><guid isPermaLink="true">https://koha.hashnode.dev/x402-explain-like-im-five</guid><category><![CDATA[AI]]></category><category><![CDATA[payments]]></category><category><![CDATA[payment gateway]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Thu, 18 Sep 2025 13:28:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1758202067377/c87a65b5-8f53-4984-a6c4-2ee856c8a7e5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758202091420/2e6c3d8c-2092-4c83-a846-2f8829f7bde6.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Galileo, explain like i'm five]]></title><description><![CDATA[AI agents are powerful, but without reliability they’re just experiments waiting to fail. That’s where Galileo steps in; giving you visibility, protection…]]></description><link>https://koha.hashnode.dev/galileo-explain-like-im-five</link><guid isPermaLink="true">https://koha.hashnode.dev/galileo-explain-like-im-five</guid><category><![CDATA[AI]]></category><category><![CDATA[observability]]></category><category><![CDATA[agents]]></category><category><![CDATA[Reliability]]></category><category><![CDATA[Evaluation]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Wed, 17 Sep 2025 15:42:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1758123495371/3c0c5bb7-ec50-4ff4-8ab2-dbd4c21b7c59.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>AI agents are powerful, but without reliability they’re just experiments waiting to fail. That’s where <strong>Galileo</strong> steps in; giving you visibility, protection, and trust in how your AI behaves at every step  </p>
<p>Check out Galileo - <a target="_blank" href="https://x.com/rungalileo"><code>https://x.com/rungalileo</code></a></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758123158119/8cdf0c3a-1bf4-4c5b-bcb5-95d313b9b49a.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[AI Agents, explain like i'm five]]></title><description><![CDATA[AI Agents are like digital interns. You give them a task, they think, use tools to do them, remember what they’ve done and loop until the job is done…]]></description><link>https://koha.hashnode.dev/ai-agents-explain-like-im-five</link><guid isPermaLink="true">https://koha.hashnode.dev/ai-agents-explain-like-im-five</guid><category><![CDATA[AI]]></category><category><![CDATA[ai agents]]></category><category><![CDATA[#ai-tools]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Mon, 15 Sep 2025 23:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1758124355214/7f888215-e75e-4076-90af-681a1d8a024e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>AI Agents</strong> are like digital interns. You give them a task, they think, use tools to do them, remember what they’ve done and loop until the job is done.  </p>
<p>ELI5:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758123837376/8d72b103-ace7-40a1-ae61-372096cae377.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-resources">Resources:</h3>
<ol>
<li><a target="_blank" href="https://www.anthropic.com/engineering/building-effective-agents">Building Effective Agents by Anthrophic</a></li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Context Window, explain like i'm five]]></title><description><![CDATA[Every AI model has a memory — but it’s not endless. That memory space is called the context window, and it decides how much of your instructions, history…]]></description><link>https://koha.hashnode.dev/context-window-explain-like-im-five</link><guid isPermaLink="true">https://koha.hashnode.dev/context-window-explain-like-im-five</guid><category><![CDATA[AI]]></category><category><![CDATA[Artificial Intelligence]]></category><category><![CDATA[ai agents]]></category><category><![CDATA[llm]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Sun, 14 Sep 2025 23:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1758124415412/f03ddbdd-609a-4d87-9294-fa4c5827f498.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every AI model has a memory — but it’s not endless. That memory space is called the <strong>context window</strong>, and it decides how much of your instructions, history, and data the AI can actually “see” at once.  </p>
<p>ELI5:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758124424430/71828129-0535-42e7-ad21-019eda0e4b0e.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[How to use SuperTokens in a VueJS app with your own UI]]></title><description><![CDATA[Learn how to integrate supertokens-web-js SDK into your VueJS application.]]></description><link>https://koha.hashnode.dev/how-to-use-supertokens-in-a-vuejs-app-with-your-own-ui</link><guid isPermaLink="true">https://koha.hashnode.dev/how-to-use-supertokens-in-a-vuejs-app-with-your-own-ui</guid><category><![CDATA[SuperTokens]]></category><category><![CDATA[UI]]></category><category><![CDATA[authentication]]></category><category><![CDATA[Security]]></category><category><![CDATA[Vue.js]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Wed, 09 Oct 2024 08:00:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1728445643469/fe9313cd-6db0-4e33-b006-c52f767013e1.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this tutorial, you will learn how to add an Email + Password Authentication to a Vue.js application using SuperTokens. We'll build a simple web application where users can sign up with their email and password, relying on SuperTokens for authentication.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bqx4cqf9k23rjh30edmh.png" alt="Demo of our app" /></p>
<p>Our <a target="_blank" href="https://supertokens-vue.vercel.app/">demo app</a> will use the <a target="_blank" href="https://supertokens.com/docs/emailpassword/introduction">Email-Password</a> recipe for authentication and a custom authentication user interface (UI) tailored for our users.</p>
<p>Before diving in, let’s look at SuperTokens, its unique architecture, and why it’s a compelling choice.</p>
<p>// Jump to the tutorial section</p>
<h2 id="heading-what-is-supertokens">What is SuperTokens?</h2>
<p>SuperTokens is an open-source authentication provider designed to deliver secure user authentication without compromising the experience for both users and developers.</p>
<p>With SuperTokens, developers can efficiently manage user sessions, securely store user data, and implement secure authentication flows using various auth strategies called <strong>recipes</strong>.</p>
<p>Thanks to its open-source philosophy, SuperTokens allows you to self-host the solution on your premises, giving you complete control over your infrastructure—all at no cost. If self-hosting feels like too much work, you can opt for the SuperTokens managed service, where SuperTokens handles all the infrastructure setup, allowing you to focus on shipping your product quickly.</p>
<h2 id="heading-supertokens-architecture-in-30-seconds">SuperTokens Architecture in 30 seconds</h2>
<p>SuperTokens is made up of three components:</p>
<ol>
<li><p><code>Frontend SDK</code>: Renders the auth UI widgets and manages user session tokens automatically</p>
</li>
<li><p><code>Backend SDK</code>: Adds auth API routes to your backend, like <code>/sign-in</code>, and<code>/sign-up</code> exposed on the same domain as your application's APIs.</p>
</li>
<li><p><code>SuperTokens Core Service</code>: This HTTP service talks to your database. It also contains the core logic for authentication. You can self-host with your database (<a target="_blank" href="https://supertokens.com/docs/emailpassword/quick-setup/core/with-docker">with docker</a> or <a target="_blank" href="https://supertokens.com/docs/emailpassword/quick-setup/core/without-docker">without Docker</a> or host it with a <a target="_blank" href="https://supertokens.com/">SuperTokens-managed service</a>.</p>
</li>
</ol>
<p>The architecture employed here is unique and different from other auth providers as the backend API layer sits right in the middle of your front end and SuperTokens.</p>
<p>This means that the front end will never talk to the SuperTokens core directly, but rather that any request made will be to the APIs exposed by the backend SDK, which will then talk to the SuperTokens core.</p>
<aside>
💡 For more information, see this 2-minute video on YouTube by Rishabh Poddar of SuperTokens on <a target="_blank" href="https://youtu.be/lUjAx75hF8I">how SuperTokens work</a>s.
</aside>

<h2 id="heading-why-supertokens">Why SuperTokens?</h2>
<ol>
<li><p>Open source: SuperTokens is free to use with no limits on the number of users—forever.</p>
</li>
<li><p>An on-premises deployment so that you control 100% of your user data using your database.</p>
</li>
<li><p>An end-to-end solution with login, sign-ups, user, and session management without all the complexities of OAuth protocols.</p>
</li>
<li><p>Ease of implementation and higher security.</p>
</li>
<li><p>Extensibility: Anyone can contribute and make SuperTokens better!</p>
</li>
<li><p><strong>Pre-built UI Components:</strong> SuperTokens offers pre-built authentication UI, such as login forms, for quick and easy integration. Alternatively, you can opt to use your custom UI.</p>
</li>
</ol>
<h2 id="heading-getting-started">Getting Started</h2>
<p>Now that we know a little about the underlying technology let's start building.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before you begin, you need:</p>
<ul>
<li><p>A basic knowledge of JavaScript and <a target="_blank" href="https://vuejs.org/guide/quick-start.html">Vue.js</a></p>
</li>
<li><p><a target="_blank" href="https://nodejs.org/en/">Node.js</a> installed on your computer</p>
</li>
<li><p>A <a target="_blank" href="https://supertokens.com/">SuperTokens</a> account</p>
</li>
</ul>
<h2 id="heading-project-setup">Project Setup</h2>
<p>To reduce the scope of this guide, you will be starting with a <a target="_blank" href="https://github.com/kohasummons/supertokens-vue">repository</a> that already has a few things set up for you:</p>
<ul>
<li><p>A Simple Vue.js web application</p>
</li>
<li><p>TailwindCSS for styling and</p>
</li>
<li><p>Vue Router for in app navigation.</p>
</li>
<li><p>An express-based backend</p>
</li>
</ul>
<p>To get started, clone the starter branch from the repository with the following command:</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> --branch starter &lt;https://github.com/kohasummons/supertokens-vue&gt;
<span class="hljs-built_in">cd</span> supertokens-vue
</code></pre>
<p>Your project directory structure will look like the tree below with that setup. The <code>...</code> indicates omitted files to keep the tree concise.</p>
<pre><code class="lang-plaintext">├── backend
│   ├── ...
│   ├── app.js
└── frontend
    ├── ...
    ├── src
    │   ├── App.vue
    │   ├── components
    │   │   ├── HelloWorld.vue
    │   │   ├── TheButton.vue
    │   ├── main.ts
    │   ├── router
    │   │   └── index.ts
    │   └── views
    │       ├── AboutView.vue
    │       ├── AuthView.vue
    │       ├── HomeView.vue
    │       └── UserView.vue
</code></pre>
<ul>
<li><p>The backend folder holds the Express.js code for the APIs</p>
</li>
<li><p>The Frontend folder contains code for the Vue.js application</p>
</li>
</ul>
<h2 id="heading-frontend">Frontend</h2>
<p>Change into the <em>Frontend</em> directory and install the <code>superTokens-web-js</code> dependency</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> frontend/
npm i -s supertokens-web-js
</code></pre>
<h3 id="heading-initializing-supertokens">Initializing SuperTokens</h3>
<p>Open <code>main.ts</code> and initialize SuperTokens</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">import</span> SuperTokens <span class="hljs-keyword">from</span> <span class="hljs-string">'supertokens-web-js'</span>;
<span class="hljs-keyword">import</span> Session <span class="hljs-keyword">from</span> <span class="hljs-string">'supertokens-web-js/recipe/session'</span>;
<span class="hljs-keyword">import</span> EmailPassword <span class="hljs-keyword">from</span> <span class="hljs-string">'supertokens-web-js/recipe/emailpassword'</span>

<span class="hljs-comment">// Several lines of code are omitted here.</span>

SuperTokens.init({
    <span class="hljs-attr">appInfo</span>: {
        <span class="hljs-attr">apiDomain</span>: <span class="hljs-string">"&lt;YOUR_API_DOMAIN&gt;"</span>, <span class="hljs-comment">// I use &lt;http://localhost:5175&gt; here</span>
        <span class="hljs-attr">apiBasePath</span>: <span class="hljs-string">"/auth"</span>,
        <span class="hljs-attr">appName</span>: <span class="hljs-string">"replace with your app name"</span>,
    },

    <span class="hljs-attr">recipeList</span>: [
        Session.init(),
        EmailPassword.init(),
    ],
});
</code></pre>
<p>In this code snippet, we set up session management network interceptors across the entire application. Our front end will now automatically save and attach session tokens to each request made to our API and auto-refresh sessions.</p>
<p>This setup also specifies the type of authentication we want to use—in this case, the <code>EmailPassword</code> recipe. Additional recipes can be added to the <code>recipeList</code> array depending on the project's needs.</p>
<p>The <a target="_blank" href="https://supertokens.com/docs/thirdpartyemailpassword/appinfo">appInfo object</a> allows us to customize our SuperTokens instance for the application, and it needs to be specified both on the frontend and backend. Some of the options it provides include:</p>
<ol>
<li><p><code>appName:</code> The name of your application</p>
</li>
<li><p><code>apiDomain:</code> The API Domain URL of your backend</p>
</li>
<li><p><code>apiBasePath:</code> The base path for the API</p>
</li>
</ol>
<h3 id="heading-add-signin-and-signup-to-your-application">Add SignIn and SignUp to your application</h3>
<p>Great! Let's add the ability for our users to sign up via our custom UI. Head to <code>AuthView.vue</code> and update with the following code:</p>
<pre><code class="lang-jsx">&lt;script setup lang=<span class="hljs-string">"ts"</span>&gt;
<span class="hljs-keyword">import</span> { signIn, signUp } <span class="hljs-keyword">from</span> <span class="hljs-string">"supertokens-web-js/recipe/emailpassword"</span>;
<span class="hljs-comment">// Several lines of code are omitted here.</span>

<span class="hljs-keyword">const</span> onSignUp = <span class="hljs-keyword">async</span> () =&gt; {
    <span class="hljs-keyword">try</span> {
        <span class="hljs-keyword">let</span> response = <span class="hljs-keyword">await</span> signUp({
            <span class="hljs-attr">formFields</span>: [{
                <span class="hljs-attr">id</span>: <span class="hljs-string">"email"</span>,
                <span class="hljs-attr">value</span>: email.value
            }, {
                <span class="hljs-attr">id</span>: <span class="hljs-string">"password"</span>,
                <span class="hljs-attr">value</span>: password.value
            }]
        })

       <span class="hljs-comment">// handle potential errors</span>
        <span class="hljs-keyword">if</span> (response.status === <span class="hljs-string">"FIELD_ERROR"</span>) {
            <span class="hljs-comment">// one of the input formFields failed validaiton</span>
            response.formFields.forEach(<span class="hljs-function"><span class="hljs-params">formField</span> =&gt;</span> {
                <span class="hljs-keyword">if</span> (formField.id === <span class="hljs-string">"email"</span>) {
                    <span class="hljs-comment">// Email validation failed</span>
                    <span class="hljs-built_in">window</span>.alert(formField.error)
                } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (formField.id === <span class="hljs-string">"password"</span>) {
                    <span class="hljs-comment">// Password validation failed.</span>
                    <span class="hljs-comment">// Maybe it didn't match the password strength</span>
                    <span class="hljs-built_in">window</span>.alert(formField.error)
                }
            })
        } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (response.status === <span class="hljs-string">"SIGN_UP_NOT_ALLOWED"</span>) {
            <span class="hljs-comment">// the reason string is a user friendly message</span>
            <span class="hljs-comment">// about what went wrong.</span>
            <span class="hljs-built_in">window</span>.alert(response.reason)
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-comment">// sign up successful.</span>
            <span class="hljs-comment">// navigate to the '/user' page</span>
            router.push({ <span class="hljs-attr">name</span>: <span class="hljs-string">'user'</span> })
        }
    } <span class="hljs-keyword">catch</span> (err: any) {
        <span class="hljs-keyword">if</span> (err.isSuperTokensGeneralError === <span class="hljs-literal">true</span>) {
            <span class="hljs-comment">// this may be a custom error message sent from the API by you.</span>
            <span class="hljs-built_in">window</span>.alert(err.message);
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-built_in">window</span>.alert(<span class="hljs-string">"Oops! Something went wrong."</span>);
        }
    }
}
&lt;/script&gt;
</code></pre>
<p>The <code>onSignUp</code> function calls the <code>signIn</code> method from <code>supertokens-web-js</code> SDK which receives the email and password. If authentication is successful, we redirect the user to the <code>"/user"</code> route.</p>
<p>Next, let's handle the <code>SignIn</code> action. Update the <code>AuthView.vue</code> with the following code:</p>
<pre><code class="lang-jsx">&lt;script setup lang=<span class="hljs-string">"ts"</span>&gt;
<span class="hljs-comment">// Several lines of code are omitted here.</span>

<span class="hljs-keyword">const</span> onSignIn = <span class="hljs-keyword">async</span> () =&gt; {
    <span class="hljs-keyword">if</span> (!email.value || !password.value) <span class="hljs-keyword">return</span>

    <span class="hljs-keyword">try</span> {
        <span class="hljs-keyword">let</span> response = <span class="hljs-keyword">await</span> signIn({
            <span class="hljs-attr">formFields</span>: [{
                <span class="hljs-attr">id</span>: <span class="hljs-string">"email"</span>,
                <span class="hljs-attr">value</span>: email.value
            }, {
                <span class="hljs-attr">id</span>: <span class="hljs-string">"password"</span>,
                <span class="hljs-attr">value</span>: password.value
            }]
        })

        <span class="hljs-keyword">if</span> (response.status === <span class="hljs-string">"FIELD_ERROR"</span>) {
            response.formFields.forEach(<span class="hljs-function"><span class="hljs-params">formField</span> =&gt;</span> {
                <span class="hljs-keyword">if</span> (formField.id === <span class="hljs-string">"email"</span>) {
                    <span class="hljs-comment">// Email validation failed</span>
                    <span class="hljs-comment">// (for example, incorrect email syntax).</span>
                    <span class="hljs-built_in">window</span>.alert(formField.error)
                }
            })
        } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (response.status === <span class="hljs-string">"WRONG_CREDENTIALS_ERROR"</span>) {
            <span class="hljs-built_in">window</span>.alert(<span class="hljs-string">"Email password combination is incorrect."</span>)
        } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (response.status === <span class="hljs-string">"SIGN_IN_NOT_ALLOWED"</span>) {
            <span class="hljs-comment">//The reason string is a user-friendly message</span>
            <span class="hljs-comment">// about what went wrong.</span>
            <span class="hljs-built_in">window</span>.alert(response.reason)
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-comment">//sign-in successful.</span>
            <span class="hljs-comment">// navigate to the "/user" page</span>
            router.push({ <span class="hljs-attr">name</span>: <span class="hljs-string">'user'</span> })
        }
    } <span class="hljs-keyword">catch</span> (err: any) {
        <span class="hljs-keyword">if</span> (err.isSuperTokensGeneralError === <span class="hljs-literal">true</span>) {
            <span class="hljs-comment">// this may be a custom error message</span>
            <span class="hljs-comment">// sent from your API.</span>
            <span class="hljs-built_in">window</span>.alert(err.message);
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-built_in">window</span>.alert(<span class="hljs-string">"Oops! Something went wrong."</span>);
        }
    }
}
&lt;/script&gt;
</code></pre>
<p>The <code>SignIn</code> function works similarly to the <code>SignUp</code> function we implemented earlier. We pass the email and password to the <code>SignIn</code> function, check for and handle any errors, and then automatically navigate the user if the action is successful.</p>
<h2 id="heading-add-signout-to-your-application">Add SignOut to your application</h2>
<p>Users who sign in to your application will also need a way to sign out. Let's add a SignOut functionality to the <code>user</code> page.</p>
<p>Open <code>Userview.vue</code> and update with the following code:</p>
<pre><code class="lang-jsx"><span class="hljs-comment">//Several lines of code are omitted here</span>
<span class="hljs-keyword">import</span> Session <span class="hljs-keyword">from</span> <span class="hljs-string">"supertokens-web-js/recipe/session"</span>;

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">onSignOut</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">await</span> Session.signOut();
    router.push({ <span class="hljs-attr">name</span>: <span class="hljs-string">'auth'</span> });
}
</code></pre>
<h2 id="heading-backend">Backend</h2>
<p>While your front end is fully integrated with SuperTokens, it isn't doing anything yet. That's because the front end will never directly talk to the SuperTokens core. Any request from the front end will be sent to the APIs exposed on your backend via the <code>supertokens-node</code> SDK, which will then talk to the SuperTokens core. Let's get our backend up and running.</p>
<p>For a quick backend setup, check out the <a target="_blank" href="https://supertokens.com/docs/thirdpartyemailpassword/quick-setup/backend">backend quick setup section in SuperTokens docs</a>.</p>
<p>Change into the <em>Backend</em> directory and install <code>supertokens-node</code> dependency</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> backend
npm i -s supertokens-node
</code></pre>
<p>Open <code>app.js</code> and update with the following code</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">import</span> supertokens <span class="hljs-keyword">from</span> <span class="hljs-string">"supertokens-node"</span>;
<span class="hljs-keyword">import</span> Session <span class="hljs-keyword">from</span> <span class="hljs-string">"supertokens-node/recipe/session/index.js"</span>;
<span class="hljs-keyword">import</span> EmailPassword <span class="hljs-keyword">from</span> <span class="hljs-string">"supertokens-node/recipe/emailpassword/index.js"</span>;
<span class="hljs-keyword">import</span> { verifySession } <span class="hljs-keyword">from</span> <span class="hljs-string">"supertokens-node/recipe/session/framework/express/index.js"</span>;
<span class="hljs-keyword">import</span> { middleware, errorHandler } <span class="hljs-keyword">from</span> <span class="hljs-string">'supertokens-node/framework/express/index.js'</span>;

supertokens.init({
    <span class="hljs-attr">framework</span>: <span class="hljs-string">"express"</span>,
    <span class="hljs-attr">supertokens</span>: {
        <span class="hljs-comment">// These are the connection details of</span>
        <span class="hljs-comment">// the app you created on supertokens.com</span>
        <span class="hljs-attr">connectionURI</span>: <span class="hljs-string">`&lt;replace with your URI&gt;`</span>,
        <span class="hljs-attr">apiKey</span>: <span class="hljs-string">`&lt;replace with your apiKey&gt;`</span>,
    },

    <span class="hljs-attr">appInfo</span>: {
        <span class="hljs-comment">// learn more: &lt;https://supertokens.com/docs/session/appinfo&gt;</span>
        <span class="hljs-attr">appName</span>: <span class="hljs-string">"replace with your app name"</span>,
        <span class="hljs-attr">apiDomain</span>: <span class="hljs-string">"&lt;YOUR_API_DOMAIN&gt;"</span>, <span class="hljs-comment">// I use &lt;http://localhost:5175&gt; here</span>
        <span class="hljs-attr">websiteDomain</span>: <span class="hljs-string">"&lt;YOUR_WEBSITE_DOMAIN&gt;"</span>,<span class="hljs-comment">// I use &lt;http://localhost:5173&gt; here</span>
        <span class="hljs-attr">apiBasePath</span>: <span class="hljs-string">"/auth"</span>,
        <span class="hljs-attr">websiteBasePath</span>: <span class="hljs-string">"/auth"</span>,
    },

    <span class="hljs-attr">recipeList</span>: [
        EmailPassword.init(), <span class="hljs-comment">// initializes signin / sign up features</span>
        Session.init(), <span class="hljs-comment">// initializes session features</span>
    ]
});
</code></pre>
<p>This will initialize the <code>supertokens-node</code> SDK and allow us to customize our authentication flow. Once again, the <code>recipeList</code> array configures the type of authentication we prefer, similar to how you did on the front end. The <code>appInfo</code> object also behaves like it was on the front end.</p>
<p>Next, let's setup <code>CORS</code> and the SuperTokens <code>middleware</code> and <code>errorHandler</code>:</p>
<pre><code class="lang-jsx"><span class="hljs-comment">// several lines have been omitted</span>

<span class="hljs-comment">// Add `cors` middleware BEFORE the SuperTokens middleware</span>
app.use(cors({
    <span class="hljs-attr">origin</span>: <span class="hljs-string">"&lt;YOUR_WEBSITE_DOMAIN&gt;"</span>,
    <span class="hljs-attr">allowedHeaders</span>: [<span class="hljs-string">"content-type"</span>, ...supertokens.getAllCORSHeaders()],
    <span class="hljs-attr">credentials</span>: <span class="hljs-literal">true</span>
}))

<span class="hljs-comment">// Add the middleware BEFORE all your routes.</span>
app.use(middleware());

<span class="hljs-comment">// you can add any other route here.</span>

app.use(errorHandler());
</code></pre>
<p>This <code>middleware</code> exposes all the auth-related API routes (like sign-in and sign-up) to the front end..</p>
<ul>
<li><p><code>POST /auth/signup</code>: For signing up a user with email &amp; password</p>
</li>
<li><p><code>POST /auth/signin</code>: For signing in a user with email &amp; password</p>
</li>
</ul>
<h3 id="heading-set-up-your-supertokens-core-instance"><strong>Set up your SuperTokens Core Instance</strong></h3>
<p>There are two ways to set up your core instance:</p>
<ol>
<li><p><strong>Self-Hosting the Core Instance</strong>: Self-hosting allows you to use all the open-source features of SuperTokens for free, regardless of "scale”. Everything is managed within your infrastructure, giving you full control over the deployment.</p>
</li>
<li><p><strong>Using the SuperTokens Managed Service</strong>:</p>
<p> With this option, SuperTokens takes care of scalability, reliability, and updates on your behalf, significantly reducing your DevOps workload. It offers the same features as the self-hosted version but with the added convenience of on-demand management and infrastructure support.</p>
</li>
</ol>
<p>For the scope of this tutorial, we'll spin a SuperTokens managed service instance.</p>
<p>Create a user account on <a target="_blank" href="https://supertokens.com/">Supertokens</a></p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mlnpboo4zglcz5juqedq.png" alt="Image showing the Create a user account step" /></p>
<ul>
<li>Select a region and click the deploy button:</li>
</ul>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fd9gmg2nm4hryte03pih.png" alt="Image showing the select region step" /></p>
<ul>
<li>After the deployment is complete, the dashboard will look similar to this</li>
</ul>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xpn0392efktggfk6dr74.png" alt="Image showing the dashboard" /></p>
<p>Finally, add <code>connectionURI</code> and <code>apiKey</code> of your SuperTokens core to your backend.</p>
<h2 id="heading-testing-it-out">Testing it out</h2>
<p>Now, we can test everything out.</p>
<p>With both the frontend and backend servers running, open your application URL in the browser. Navigate to the Auth page and sign up or sign in.</p>
<p>You'll be redirected to the User page if the sign-in or sign-up is successful.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdi4hbbo51vj7ezppa33.png" alt="Demo of auth setup" /></p>
<ul>
<li>The User page in our demo displays some metadata about the user. That is a little task for you to implement. Look through the <a target="_blank" href="https://supertokens.com/docs/emailpassword/common-customizations/get-user-info#fetching-information-using-the-users-id">docs</a> and give it a shot.</li>
</ul>
<p>Useful Resource: <a target="_blank" href="https://supertokens.com/docs/emailpassword/common-customizations/get-user-info#fetching-information-using-the-users-id">https://supertokens.com/docs/emailpassword/common-customizations/get-user-info#fetching-information-using-the-users-id</a></p>
<h3 id="heading-protecting-your-frontend-routes">Protecting your Frontend Routes</h3>
<p>You can keep unauthenticated users away from certain page routes using navigation guards.</p>
<p>To protect the User Page route, Navigate to the <code>router</code> directory and update <code>index.ts</code> with the following code:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> Session <span class="hljs-keyword">from</span> <span class="hljs-string">'supertokens-web-js/recipe/session'</span>;

<span class="hljs-comment">// several omitted lines of code</span>

router.beforeEach(<span class="hljs-keyword">async</span> (to, <span class="hljs-keyword">from</span>, next) =&gt; {
  <span class="hljs-keyword">if</span> (to.name === <span class="hljs-string">'user'</span> &amp;&amp; !(<span class="hljs-keyword">await</span> Session.doesSessionExist())) {
      next({ <span class="hljs-attr">name</span>: <span class="hljs-string">'auth'</span> })
  }
    <span class="hljs-keyword">else</span> {
        next();
    }
})
</code></pre>
<p>The <code>router.beforeEach</code> function runs before every route is resolved. We’ve added logic to check if a user session exists. If it does, it navigates to the user page; otherwise, it redirects to the auth page, prompting users to sign in.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>With this tutorial, you've successfully implemented Email + Password authentication in a Vue.js application using the SuperTokens SDK and a Custom UI. You’ve learned how to set up SuperTokens on both the frontend and backend, create a SuperTokens managed service, and protect your frontend routes using navigation guards in combination with SuperTokens.</p>
<p>To learn more about SuperTokens, check out the <a target="_blank" href="https://supertokens.com/docs/">SuperTokens Documentation</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Fix: DrizzleORM could not resolve peer dependency error with NextJS 14]]></title><description><![CDATA[My best guess is you're reading this because you saw it too: the peer dependency error in your terminal while installing drizzle-orm in your Next.js 14…]]></description><link>https://koha.hashnode.dev/fix-drizzleorm-nextjs</link><guid isPermaLink="true">https://koha.hashnode.dev/fix-drizzleorm-nextjs</guid><category><![CDATA[DrizzleORM]]></category><category><![CDATA[Next.js]]></category><category><![CDATA[error]]></category><category><![CDATA[fix]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Sat, 06 Jul 2024 15:46:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1720280634836/49f92331-aebc-4756-91e2-73260c1b8f19.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>My best guess is you're reading this because you saw it too: the peer dependency error in your terminal while installing <code>drizzle-orm</code> in your Next.js 14 application. Let's fix it.</p>
<h2 id="heading-a-peek-at-the-error">A Peek at the error</h2>
<p>Here's a clipped view of my setup <code>package.json</code>:</p>
<pre><code class="lang-bash"><span class="hljs-string">"dependencies"</span>: {
    ...
    <span class="hljs-string">"next"</span>: <span class="hljs-string">"14.2.4"</span>,
    <span class="hljs-string">"react"</span>: <span class="hljs-string">"^18.3.1"</span>,
    <span class="hljs-string">"react-dom"</span>: <span class="hljs-string">"^18.3.1"</span>,
  },
</code></pre>
<p>When I run <code>npm install drizzle-orm</code> I get slammed with a conflicting peer dependency error. Here’s what it looks like;</p>
<pre><code class="lang-bash">❯ npm install drizzle-orm
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: xxx@0.1.0
npm ERR! Found: react@18.3.1
npm ERR! node_modules/react
npm ERR!   peer react@<span class="hljs-string">"&gt;=18 || &gt;=19.0.0-beta"</span> from @clerk/clerk-react@5.2.7
npm ERR!   node_modules/@clerk/clerk-react
[...]
npm ERR! Could not resolve dependency:
npm ERR! drizzle-orm@<span class="hljs-string">"*"</span> from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@18.2.0
npm ERR! node_modules/react
npm ERR!   peer react@<span class="hljs-string">"18.2.0"</span> from react-native@0.74.3
npm ERR!   node_modules/react-native
[...]
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this <span class="hljs-built_in">command</span> with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
</code></pre>
<p><strong>Translating to human speak:</strong></p>
<p>While resolving <code>xxx@0.1.0</code>, I found <code>react@18.3.1</code></p>
<pre><code class="lang-bash">npm ERR! While resolving: xxx@0.1.0
npm ERR! Found: react@18.3.1
</code></pre>
<p>However, I can't resolve <code>drizzle-orm@"*"</code> from the root project because I need <code>react@18.2.0</code> and it conflicts with the <code>react@18.3.1</code> I found earlier.</p>
<pre><code class="lang-bash">npm ERR! Could not resolve dependency:
npm ERR! drizzle-orm@<span class="hljs-string">"*"</span> from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@18.2.0
</code></pre>
<h2 id="heading-the-fix">The Fix</h2>
<p>I found that updating all the dependencies fixed the issue.</p>
<p><strong>Step 1: Update the dependencies</strong></p>
<p>Run the following command to update all existing dependencies listed in your <code>package.json</code> file to their latest compatible versions;</p>
<pre><code class="lang-bash">npm update --save
npm update --save-dev
</code></pre>
<p><strong>Step 2: Install drizzle-orm</strong></p>
<p>Finally, install the <code>drizzle-orm</code> package as a dependency:</p>
<pre><code class="lang-bash">npm install --save drizzle-orm
</code></pre>
<p>That should fix it!</p>
<h2 id="heading-readings">Readings</h2>
<ul>
<li><a target="_blank" href="https://sagrawal003.medium.com/managing-dependency-conflicts-in-node-js-grow-together-by-sharing-knowledge-40b6cd1c7d2e"><strong>Managing Dependency Conflicts in Node.js</strong></a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How to kill port 3000]]></title><description><![CDATA[Port 3000 needs no introduction. It's the default port for most web servers including your favourite frameworks. Once you lose your developer virginity…]]></description><link>https://koha.hashnode.dev/how-to-kill-port-3000</link><guid isPermaLink="true">https://koha.hashnode.dev/how-to-kill-port-3000</guid><category><![CDATA[Bash]]></category><category><![CDATA[terminal]]></category><category><![CDATA[Linux]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Thu, 04 Jul 2024 23:45:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1720136584369/484efa17-35aa-40df-b634-d644b740d65e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Port 3000 needs no introduction. It's the default port for most web servers including your favourite frameworks. Once you lose your developer virginity, there is no escape; port 3000 will always pop up.</p>
<p>So, a process runs on a port. A port can only accommodate one process at a time. A previously occupied port becomes available once the process taking up that space concludes its operation or the process is terminated.</p>
<p>Your machine reminds you of this every time it blasts the <code>Server Error: this port is already in use</code> message or a similar one across your terminal.</p>
<pre><code class="lang-bash">Server Error: this port is already <span class="hljs-keyword">in</span> use
</code></pre>
<p>Thankfully, most tools that need to listen to a port gracefully handle port unavailability. For example, NextJs will attempt to run on <code>3000</code>, if occupied it will revert to<code>3001</code> and so on.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1720135616171/c9afddf3-2262-4d4f-ba92-04001233a699.png" alt class="image--center mx-auto" /></p>
<p>Our mission: Let's kill port 3000 and set it free</p>
<h2 id="heading-killing-port-3000">Killing Port 3000</h2>
<p>The <code>kill-port</code> package is the perfect port assassin.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Kill a single port</span>
npx kill-port [PORT]

<span class="hljs-comment"># Kill multiple ports</span>
npx kill-port [PORT1] [PORT2] [PORTN]
</code></pre>
<p>Running any of the commands above terminates the process on the port passed into <code>[PORT]</code> and you can send multiple ports to their death using the second variant.</p>
<p>You might find several ways to kill ports on Google but I promise you; none is more declarative and self-explanatory than the version I showed you.</p>
<p>I hope this helps you, Port Killer.</p>
<h3 id="heading-readings">Readings</h3>
<ul>
<li><a target="_blank" href="https://blog.jim-nielsen.com/2023/short-history-of-port-numbers/">A Short, Totally Unofficial, History of Port Numbers in Web Development - Jim Nielsen’s Blog (jim-nielsen.com)</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Get Started with Gaming On Scroll using  Paima Engine]]></title><description><![CDATA[What if you could build trustless Web3 games entirely with Web2 programming languages you're already familiar with? Well, with Paima Engine, you can! Web3…]]></description><link>https://koha.hashnode.dev/gaming-on-scroll-using-paima-engine</link><guid isPermaLink="true">https://koha.hashnode.dev/gaming-on-scroll-using-paima-engine</guid><category><![CDATA[Paima]]></category><category><![CDATA[Web3]]></category><category><![CDATA[scroll]]></category><category><![CDATA[ZKP]]></category><category><![CDATA[gaming]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Thu, 08 Feb 2024 21:42:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707421429761/a5a0e256-00a9-4d02-ae0b-da9550120e31.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>What if you could build trustless Web3 games entirely with Web2 programming languages you're already familiar with? Well, with <a target="_blank" href="https://paimastudios.com">Paima Engine</a>, you can!</p>
<p>Web3 games bring fresh vibes to the community, yet their development demands a high level of technical skill and interoperability. Moreover, a lot of the current game engines are optimized for Web2 games, which are centred around centralized servers and databases, lacking the essential features required for Web3 games, such as decentralized ownership, play-to-earn incentives, and cross-chain compatibility.</p>
<p>The Paima Engine solves all these problems by allowing developers to build Web3 games using a familiar stack in just days. In this guide, we are going to get familiar with the Paima Engine, explore its potential to build games on Scroll and then deploy a sample project to the Scroll network.</p>
<h2 id="heading-what-is-scroll">What is Scroll?</h2>
<p><a target="_blank" href="https://docs.scroll.io/en/technology/">Scroll</a> is an EVM-equivalent Layer 2 scaling solution for Ethereum that uses ZK (zero Knowledge) technology. It is more accessible and responsive, extending Ethereum's capabilities down to the bytecode, enabling apps to scale without any surprises. Scroll is compatible with Ethereum at the bytecode level, which means existing Ethereum apps can migrate onto Scroll as-is, and at a significantly reduced cost.</p>
<p>Scroll, being a ZK rollup makes it fast, cheap and super scalable which are all the things that sound exciting when building games.</p>
<h2 id="heading-what-is-paima-engine">What is Paima Engine?</h2>
<p>Paima Engine is a framework built by Paima Studios for creating app-specific layer 2s (L2s) as sovereign rollups. That means: apps can publish transactions to a blockchain for ordering and data availability, but use its code to determine the correct app state. It is super-optimized for games, gamification and autonomous worlds.</p>
<p>Paima engine allows devs to deploy games using Web2 stack while not having to worry about the complexities of blockchain integration. It pioneers the solution for trustless open-source gaming primitives which were not possible in the Web2 world. Paima also supports cross-chain gameplay in that players can access the same game from different blockchains and wallets without compromising their identity or assets.</p>
<p>Games &amp; apps written using Paima Engine are non-custodial, meaning user funds are not at risk even if the game/app gets hacked. These two, in combination, make Paima Engine the cheapest, fastest and safest way to start building completely trustless Web3 games. Let's take a quick look at the problems Paima Engine solves for gaming in web3.</p>
<h2 id="heading-why-does-the-paima-engine-exist">Why does the Paima Engine exist?</h2>
<p>Before Paima, game developers had to grapple with tons of blockers to build fully decentralized games. Let's discuss these reasons and in doing so highlight the need for Paima:</p>
<h3 id="heading-development-is-expensive">Development is Expensive</h3>
<p>Building on the blockchain can be quite expensive. There is the cost of minting the NFTs, the cost of auditing the smart contracts and also the technical cost of having to write the smart contracts in strictly EVM-compatible language(Solidity or Plutus).</p>
<p>With Paima Engine, things are different; Devs can apply their years of knowledge in JavaScript, relational databases, and all parts of the classic Web2 stack with Paima Engine, while fully taking advantage of the bleeding edge in Layer-2 blockchain technology.</p>
<h3 id="heading-web3-is-risky">Web3 is Risky</h3>
<p>Software gets hacked every day and with the blockchain, the impact can be devastating. In 2022 alone, over $3 billion was stolen in hacks. And with Web3 Gaming where assets carry value, this volatility raises serious concern and spotlights the need for a better approach.</p>
<p>Paima Engine, out-of-the-box is committed to security. It protects users even in the case of hacks allowing brands to build web3 applications without worrying. Since the layer 2 state machines are deterministic and verifiable by anyone, any malicious or invalid transactions can be readily detected and reversed by the network, ensuring enhanced security and reliability for all users. In addition, users can always withdraw their assets from the layer 2 network to the layer 1 blockchain at any time, ensuring their safety and sovereignty.</p>
<h3 id="heading-user-acquisition-is-difficult">User acquisition is difficult</h3>
<p>There are currently over 1000+ chains running in the blockchain ecosystem and each has its community. This fragmentation of the user base makes it difficult to onboard users to games.</p>
<p>With Paima Engine, we can target the entire web3 Space regardless of the chain and network. This alleviates the friction of driving and attracting diverse communities to use the dApp.</p>
<h3 id="heading-fast-iteration-is-really-difficult">Fast Iteration is really difficult</h3>
<p>With Smart Contracts, you only have one shot at getting it right. Iterating and redeploying the contracts requires going through Security Audits (which is quite expensive). While Immutability is one of the blockchain's attractive features, for games it's a huge friction. It's almost impossible to retract already distributed items like NFTs from the users to rebalance the system or modify the contracts.</p>
<p>Paima Engine combats this premise by minimizing the number of static data in the dApp. Historical Web3 games rely on tons of NFTs that are expensive to Mint and hard to update. Paima Engine instead reduces the amount of NFTs used and introduces NFT compression and Stateful NFTs that are updateable. This means that developers can use the layer 2 state machines to add extra information and functionality to the layer 1 NFTs, allowing them to change over time based on user actions or game logic.</p>
<h2 id="heading-build-and-deploy-games-to-scroll-using-paima-engine">Build and Deploy Games to Scroll using Paima Engine</h2>
<h3 id="heading-what-you-will-need">What you will need</h3>
<ul>
<li><p><a target="_blank" href="https://www.npmjs.com/">npm</a> and <a target="_blank" href="https://nodejs.org/en">node.js</a> installed.</p>
</li>
<li><p>Ethereum wallet preferably <a target="_blank" href="https://metamask.io/">Metamask</a> Installed.</p>
</li>
<li><p>ETH on Scroll Testnet (Get test ETH / Bridge from the <a target="_blank" href="https://docs.scroll.io/en/user-guide/faucet/">Faucet</a>)</p>
</li>
<li><p>A desire to learn!</p>
</li>
</ul>
<h3 id="heading-setting-up-paima-engine">Setting up Paima Engine</h3>
<p>Setting up your first Paima project is straightforward. You can choose to either <a target="_blank" href="https://docs.paimastudios.com/home/setup/how-to-use-paima-engine/">start from scratch</a> or use a template provided by Paima Studios to bootstrap with all of the essentials. In this guide, we will be going the template route.</p>
<p>To initialize a game using a Paima game template, run the command below to create a new directory <code>paima-game-scroll</code> and clone the <a target="_blank" href="https://github.com/PaimaStudios/paima-game-templates"><code>paima-game-templates</code></a> git repo to your local machine.</p>
<pre><code class="lang-bash">mkdir paima-game-scroll
<span class="hljs-built_in">cd</span> paima-game-scroll
git <span class="hljs-built_in">clone</span> https://github.com/PaimaStudios/paima-game-templates.git
</code></pre>
<p>Once you've successfully cloned the repo, navigate to the <code>rock-paper-scissors</code> template which we will use for the rest of the guide.</p>
<p>While in the <code>rock-paper-scissors</code> directory, run the command below to initialize the project.</p>
<pre><code class="lang-bash">npm run initialize
</code></pre>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">You need to be running the latest node version (20.xx.xx) to run the command above.</div>
</div>]]></content:encoded></item><item><title><![CDATA[Koha vs The World]]></title><description><![CDATA[Koha's Digital Garden to keep track of the time it takes from the 4th of December to speak at a global conference.]]></description><link>https://koha.hashnode.dev/koha-vs-the-world</link><guid isPermaLink="true">https://koha.hashnode.dev/koha-vs-the-world</guid><category><![CDATA[xDays]]></category><category><![CDATA[DevRel]]></category><category><![CDATA[Developer]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Mon, 04 Dec 2023 05:18:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1701666505988/78940447-e884-4549-b1fc-9a0ad9c80813.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>December is a new year. Don't ask me to explain what that means. I say that every month. No need to wait for 365 days to recalibrate myself. 30 Days seems like a fair distance to travel, pause, re-evaluate, and then redeploy myself to action. This time I have a crazy dream. This dream requires that I provide so much value and impact that the big stage wants to hear my voice. This is my public tracker of the time it will take me from today(4/12/2023) to X(variable) to speak on the global planes. Let's begin.</p>
<h3 id="heading-day-1">Day 1</h3>
<p><strong>5:00AM</strong> - I'm awake by 5 AM to do what I have done for months now. Don't be weird. Ragna is awake too. My Sweet Sweet Machine who obeys my every keytap. Again, don't be weird. My mail is open. I see a notification. <a target="_blank" href="https://www.ethdenver.com/apps/speak?utm_source=ActiveCampaign&amp;utm_medium=email&amp;utm_content=ETHDenver+Speaker+Applications+Are+Open%21&amp;utm_campaign=%28SHORTENED%29+SPEAKER+APPLICATION+%231%3A+APPLICATIONS+ARE+LIVE+%28Copy%29&amp;vgo_ee=Sdy5OvNY%2Bd91t%2FUqHCBwZAJL2tzej1E1NFUPxlUcHkykVQad1uJuIb1A%3AsiZJOi2t6r0EUivISWUEZ4Of194qSTNY">ETHDenver Speaker Applications Are Open!</a></p>
<p><img src="https://ci3.googleusercontent.com/proxy/hHf_YnlfsW9bmYVpsZu68udsvbmguzC8YIokx-NG8uZGLE1yPFcKTL56LHXcFDEfaLDyUwMX-vEFBLDLT0FI3MjMfZBsLLeaBBhwJTp5oaDcyYZ7EOKw85JfxDyNWOTJFZTiMX7Y9ilDWzA6didSCkEqmrQyTI3rWrb89ZNMJ5MGxTsC0qia3vN6MFDLexEN3rCJfRX5fg7rqTeWm8PjTNROExPtZMAZ-CMZIHh3fAlLmV0=s0-d-e1-ft#https://content.app-us1.com/cdn-cgi/image/dpr=2,fit=scale-down,format=auto,onerror=redirect,width=650/EVxKn/2023/08/02/83655d1f-fa20-472e-ac8b-8645d3c48c3b.png" alt /></p>
<p>I intend to skim through the applications and see if it's for me to apply or wait... I might just say "flaminzoooo" and send in a topic. Let the universe be the discerning one. I am shameless. For now.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Applications</td><td>Status</td></tr>
</thead>
<tbody>
<tr>
<td><a target="_blank" href="https://www.ethdenver.com/apps/speak?utm_source=ActiveCampaign&amp;utm_medium=email&amp;utm_content=ETHDenver+Speaker+Applications+Are+Open%21&amp;utm_campaign=%28SHORTENED%29+SPEAKER+APPLICATION+%231%3A+APPLICATIONS+ARE+LIVE+%28Copy%29&amp;vgo_ee=Sdy5OvNY%2Bd91t%2FUqHCBwZAJL2tzej1E1NFUPxlUcHkykVQad1uJuIb1A%3AsiZJOi2t6r0EUivISWUEZ4Of194qSTNY">EthDenver</a></td><td>🔃</td></tr>
</tbody>
</table>
</div><h3 id="heading-day-2">Day 2</h3>
<p>I woke up today with a sore. Today is gonna be epic. Let's goooooo.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Applications</td><td>Status</td></tr>
</thead>
<tbody>
<tr>
<td>React Summit - <a target="_blank" href="https://docs.google.com/forms/d/e/1FAIpQLSfeqfjOglU2yyJtVK7AR5gt_tkby8YVXNCCywIMSc9npGlnLA/viewform">CFP</a></td><td>🔃</td></tr>
<tr>
<td><a target="_blank" href="https://opensourcedesign.net/2023/11/14/fosdem-cfp-2024">FOSDEM</a></td><td>🔃</td></tr>
</tbody>
</table>
</div><h3 id="heading-day-3">Day 3</h3>
<p>I'm still getting used to this life. Shared a couple of the CFPs with Kenny and had a long day of breathing in and out oxygen. That's it.</p>
<h3 id="heading-day-4">Day 4</h3>
<p><strong>11:06 pm</strong> - Still slinging about. I should be soaking in the bassless buzzing of Lagos at this same time tomorrow. All CFPs are looking far away and would require some form of sponsorship to get to. Eriol has yet to respond to my inquiry if FOSDEM would provide some form of travel sponsorship to speakers; <em>[7/12/23]</em></p>
<h4 id="heading-wanna-contribute">Wanna Contribute!</h4>
<p>Well, you can. Here's how:</p>
<ul>
<li><p>Leave a comment and say nice words. Don't be awful. Please, It's painful enough to be broke.</p>
</li>
<li><p>Leave a comment and send me links to Call-For-Speakers! Thank youuuuu.</p>
</li>
<li><p><a target="_blank" href="https://www.buymeacoffee.com/koha">Buy Me A Coffee</a>! or Two. Or Three.</p>
</li>
<li><p>Like this piece. Did you know that you can tap on the like button up to 10 times for a mega like? Give it a shot!</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[A Skeptics Guide to Web5]]></title><description><![CDATA[for those who do not believe in a future with self-ownership, this is for you.]]></description><link>https://koha.hashnode.dev/a-skeptics-guide-to-web5</link><guid isPermaLink="true">https://koha.hashnode.dev/a-skeptics-guide-to-web5</guid><category><![CDATA[dif]]></category><category><![CDATA[DIDCOMM]]></category><category><![CDATA[web5]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[data]]></category><category><![CDATA[ownership]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Tue, 28 Nov 2023 16:16:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1701189055597/50791e8e-6188-431e-bb8b-5e779a721e36.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>"Nothing on the Internet belongs to you."</p>
<p>When I made this statement at a recent conference I spoke at, I saw the eager faces of the audience, who already looked at me with curiosity recoil. The Gospel of Web5 came with a shocking revelation, and the truth is often hard to swallow.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1701189716313/737e63e7-9790-4b83-be87-a2ea00156867.png" alt class="image--center mx-auto" /></p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Join the Web5Africa Community - <a target="_blank" href="https://dub.sh/web5africa-wa">https://dub.sh/web5africa-wa</a></div>
</div>

<p>In this piece, my intention is to give you a breakdown of the entire idea behind Web5 without all the technical stuff and really get into the Whats, The Whys, and The Hows.</p>
<p>Hopefully, with all the powers and magic that be, I will be able to get you up to speed.</p>
<h2 id="heading-before-we-begin">Before we begin...</h2>
<p>Let's take a closer look at the current state of things. The Internet is a big, vast space of people and time. It existed way before the Twitter (X), Facebook, and Reddit of the modern world. The first version of the web, though, could have been more fun. Your current superpowers did not exist. You could not like, share, or even serve your hot takes on stuff you found on the Internet. It was one-sided, ruled by lords called <em>WebMasters</em>, and needed to <a target="_blank" href="https://worldwideweb.cern.ch/timeline/">evolve fast</a>. That first version is what <strong>Web1</strong> looked like.</p>
<p>Webmasters put up webpages. You and I consume them no questions asked, and share our 2 cents with friends and families that we can see and touch; there was no way to share that on the Internet.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1701237994496/ac75dc86-9204-416d-b7f2-7bbb0bed2107.png" alt class="image--center mx-auto" /></p>
<p>With the surge in innovation and technology and a thirst for more participation, <strong>Web2</strong> has birthed what you have now. The Twitters, The Gmails, OnlyFans, and the whole damn web, for the most part.</p>
<p>When I share this post in the Twitterverse, I expect Twitterns (Twitter Users) to like, share, reply, and hopefully not drag me. That is much more fun than the previous way of things made possible because we now have a form of "Identification" on the web.</p>
<p>Every human can claim a "tag" that will separate his essence from the next person. With this tag, the new webmasters, Google, Facebook, Twitter, et al., can house the data of each person and then use that to enable participation and individuality.</p>
<p>This is what <a target="_blank" href="https://hashnode.com/@techgirl1908">Angie Jones</a> referred to as <strong>The Account Model</strong> of Web2.</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/LPzpeFfLvQs?si=YDvImmYtEG6sookd">https://youtu.be/LPzpeFfLvQs?si=YDvImmYtEG6sookd</a></div>
<p> </p>
<p>Fast Forward a couple of new techs later and a few billions of revenue from selling your data to the highest bidder; we realised that we need more individual control over how the internet stores our data.</p>
<p>The question was, "How can I have more control over my data, content, and assets securely, boycotting all the new self-ordained webmasters?" The answer to this question was <strong>Web3.</strong> A fresh new form of the web enabled by the Blockchain where data is cryptographically locked, and every participator has complete authority over the store and intent of their data. The Blockchain is open and decentralised; for the first time, actual data ownership was activated.</p>
<p>With these newfound superpowers, we built a new empire that allowed cross-border inclusion in meaningful things like financial structures and digital ownership, which was a fluke in Web2. So what's next?</p>
<h2 id="heading-a-good-day-to-web5">A Good Day to Web5...</h2>
<p>Once upon a time, Twitter was just "Twitter" and not "X (formerly Twitter)". Twitter handled the @twitter user name on X and shared memes and stingy updates as the overlord pleased. That was a long time ago</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1701256712257/eae8dbf7-66e9-4a7c-8418-2cf549804f14.png" alt class="image--center mx-auto" /></p>
<p>Twitter is rebranding to X and claiming the username @x is part of this new branding effort. <a target="_blank" href="https://orangephotography.com/aboutus/team/gene-hwang/">Gene Huang</a> handled the @x account. He owned it. He has built his brand around the single-letter username.</p>
<p>However, when the overlord X came calling and sought the username Gene has held on to for more than seven years, you can probably guess what happened next. X claimed the @x username from Gene and assigned him <a target="_blank" href="https://twitter.com/x12345678998765">@x12345678998765</a>. A massive drop in dopeness and a clarion call that <em>Nothing on the Internet belongs to you</em>, even your usernames and emails.</p>
<p>The very fabric of your online identity can be ripped away faster than a laser will slice through butter. Crazy!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1701262753444/3b772a4f-34af-4141-8db1-815e6c6694df.png" alt class="image--center mx-auto" /></p>
<p>Hence, <strong>Web5</strong>. A fresh take on how we build web applications. An act of decoupling where data is not tied to the app we use. A shift towards more individualistic and total ownership of not just your data but also your identity.</p>
<p>What if you can move to a new social network and bring over your data from the previous social network? What if you can also migrate your identity and plug it in and out of services as you please? What if you can store your data and identity in your desired stores? What if? What if? Lots of What-ifs.</p>
<p>We are building towards that future with Web5, where the what-ifs of today are the reality of the day.</p>
<h2 id="heading-whats-next">What's next...</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1701263178797/203998a5-f57d-4821-a28b-02d4fc8e56b0.png" alt class="image--center mx-auto" /></p>
<p>I made a promise to be as feeble as possible with this piece. The next part of this series will explore how web5 can make all this happen. You can like (tap multiple times) and share this piece. You should leave a comment; I also want to hear your thoughts. My goal remains pure and true: to do all I can to Web5 you.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=h1LtmCqFOGU&amp;t=17s">https://www.youtube.com/watch?v=h1LtmCqFOGU&amp;t=17s</a></div>
<p> </p>
<p>Until the next time, remember, <strong><em>Nothing on the internet belongs to you</em></strong>.</p>
<p>Love, your favourite neighbourhood devrel.</p>
<h3 id="heading-resources">Resources</h3>
<p>📕 What is Web5?</p>
<p>📕 <a target="_blank" href="https://blackgirlbytes.dev/whats-the-point-of-web5">What is the point Web5?</a></p>
<p>📕 <a target="_blank" href="https://tbdevs.hashnode.dev/the-illusion-of-data-ownership">The Illusion of Data Ownership</a></p>
]]></content:encoded></item><item><title><![CDATA[Coffee with AWS Cloud Club Captains in Africa]]></title><description><![CDATA[This was fun! Let's do more.]]></description><link>https://koha.hashnode.dev/coffee-with-aws-cloud-club-captains-in-africa</link><guid isPermaLink="true">https://koha.hashnode.dev/coffee-with-aws-cloud-club-captains-in-africa</guid><category><![CDATA[DevRel]]></category><category><![CDATA[Developer Advocate]]></category><category><![CDATA[AWS]]></category><category><![CDATA[Africa]]></category><category><![CDATA[Developer]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Thu, 02 Nov 2023 15:58:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1698933644497/3e1ac79a-a1de-4e45-bafb-03f7890fa038.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Would you believe it if I told you we now have about 20 <a target="_blank" href="https://aws.amazon.com/developer/community/students/cloudclubs/?community-captains-all.sort-by=item.additionalFields.sortPosition&amp;community-captains-all.sort-order=asc&amp;awsf.filter-location=*all&amp;awsf.filter-year=*all">AWS Cloud Club</a> (CC) Captains In Africa and 87 Cloud Club Captains in total around the world? That's raging cool!</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/X4x3-M8NSRs">https://youtu.be/X4x3-M8NSRs</a></div>
<p> </p>
<p>You know what's even more impressive? Cloud Clubs Program started just less than a year ago at the time of writing this note. In that time, the Developer Relations team supporting the AWS Cloud Clubs Program has won some <a target="_blank" href="https://devrelawards.com/">pretty chill awards</a> due to the Program's Impact on the developer community.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698929059350/4dbef83c-5aca-4c2c-930b-d4e560fa8059.png" alt class="image--center mx-auto" /></p>
<p>AWS Cloud clubs have supported and organized over <a target="_blank" href="https://www.meetup.com/pro/cloud-clubs/">500+ cloud-focused events</a> that have helped local community members get good with cloud stuff. Don't believe me? Here's <a target="_blank" href="https://www.linkedin.com/posts/kohasummons_aws-awscertifiedcloudpractitioner-cloudcomputing-activity-7125802361742049280-Fnq5?utm_source=share&amp;utm_medium=member_desktop">proof</a> right out of the community I serve:</p>
<p>Meet Daniel, a cloud club member at the <a target="_blank" href="https://www.meetup.com/en-AU/aws-cloud-club-the-university-of-ilorin/">University of Ilorin</a> who participated in the cloud boot camp we organized and aced the cloud practitioner certification exam afterward.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698929341399/e0aa40ed-e96c-4f6f-9dd2-90432a26b3b1.png" alt class="image--center mx-auto" /></p>
<p>This is a testimony to all the hard work and dedication that Cloud Club captains worldwide are infusing into the mission to drive value and impact into their local community.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698929945838/a05d706b-408a-44df-b8f6-208a19fa7a10.png" alt class="image--center mx-auto" /></p>
<p>So that left me curious and eager to meet all the fantastic folks leading the programs in their respective communities right out of Africa. And Boom, just like that, I scheduled a meet-and-greet coffee chat for the 1st of November, 2023, and the rest, they say, "is history" 🔥.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698930096393/d1b358e7-799d-4140-b2a5-fadafa1359db.png" alt class="image--center mx-auto" /></p>
<p>I got to meet <a target="_blank" href="https://www.linkedin.com/in/mhbangie/">Mohammed Bangie</a>. He leads the Cloud Club Community at the University of Witwatersrand. Trust me, we also messed up with the pronunciation😂 at first, but he was kind and sweet enough to teach us the right way to say it. Sadly, Mohammed couldn't make the final picture cause of some city-wide technical issue.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698930495817/4cc3323a-494d-4ee5-833f-ce4e4fb7d29f.png" alt class="image--center mx-auto" /></p>
<p>Then, there is <a target="_blank" href="https://www.linkedin.com/in/tochukwuchukwure/">Tochukwu Chukwure</a>. The Cloud Club Community at the Federal University of Owerri is lucky to have him. By day, he serves and mentors Cloud Club members. By Night, he wears his superhero cape and dives into product deep waters, testing them for bugs and abnormalities as a QA Engineer. Ohhhh and Happy birthday, T. More wine in your cup and chicken wings on your plate.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698931081784/9b250c15-3ec1-4fa0-b7a1-94868f64c984.png" alt class="image--center mx-auto" /></p>
<p>And now, for the newest, freshest, and newly minted cloud club captain to join the family, meet <a target="_blank" href="https://www.linkedin.com/in/delia-ayoko">Delia Ayoko</a>. She is a super fun and cheerful lady who wears an infectious smile.</p>
<p>She joined the ranks of the CC captains less than a month ago and is getting ready to host her first event. It brings me much Joy and fulfillment knowing she won't be alone. I got to know Delia is also a member of the AWS Community Builder program, and I'm gonna be knocking on her doors for <a target="_blank" href="https://dev.to/delia/how-i-got-into-aws-as-a-community-builder-4181">insights</a> as I prepare to apply to the program in the next season.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698931524981/bb3699d0-1fc0-4067-b0f2-717b8ea6af14.png" alt class="image--center mx-auto" /></p>
<p>To sum it up, the chat was fun, and It sparked ideas, discussion, and comments on how we can synergize our efforts and impact across communities. We kinda have something brewing, so stay tuned for more info when that finally happens.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698931863336/edf676a9-5903-489d-a7a0-375210dd42fd.png" alt class="image--center mx-auto" /></p>
<p>I also shared that the first-ever cloud club symposia in Africa will happen soon - in January 2024. Okay, okay, maybe not that soon, but it's closer than it looks. We've got the call for speakers open, and you can <a target="_blank" href="https://rebrand.ly/speakersforclubsymposium">apply</a> to speak at the symposia.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698932135497/97779659-f473-4cce-86eb-d6aef2b17a6b.png" alt class="image--center mx-auto" /></p>
<p>I am so happy to belong to the Cloud Club family, and I'm pumped for what the future holds.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698932810579/41a0893a-fd64-4149-9c35-05fa0d024ffd.png" alt="AWS Cloub Captains Family at Community Day, WA. with Thembile Ndlovu of AWS." class="image--center mx-auto" /></p>
<p>If you are considering starting an AWS cloud club on campus, <a target="_blank" href="https://aws.amazon.com/developer/community/students/cloudclubs/?community-captains-all.sort-by=item.additionalFields.sortPosition&amp;community-captains-all.sort-order=asc&amp;awsf.filter-location=*all&amp;awsf.filter-year=*all&amp;awsm.page-community-captains-all=1&amp;community-captains-all.q=Joshua&amp;community-captains-all.q_operator=AND">apply</a> when the application comes up. It's a fulfilling experience.</p>
<p>Massive shoutout to all the <a target="_blank" href="https://aws.amazon.com/developer/community/students/cloudclubs/">Cloud Captains</a> everywhere. You all rock! Until the next coffee chat, brothers and sisters. Stay blessed.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698933089904/d66a79a9-b6a7-4403-b58e-5a46c4531e43.png" alt class="image--center mx-auto" /></p>
<p>Love, your friendly Neighbourhood devrel 🥑 who uses <a target="_blank" href="https://cursor.sh/">cursor</a></p>
]]></content:encoded></item><item><title><![CDATA[On speaking at DevFest'23, developer relations and learning in public...]]></title><description><![CDATA[As October 2023 winds down, I can't help but think about all the wild stuff that went down in the tenth month of this epic year! This was the month I spoke…]]></description><link>https://koha.hashnode.dev/on-speaking-at-devfest23-developer-relations-and-learning-in-public</link><guid isPermaLink="true">https://koha.hashnode.dev/on-speaking-at-devfest23-developer-relations-and-learning-in-public</guid><category><![CDATA[DevRel]]></category><category><![CDATA[Developer]]></category><category><![CDATA[#learning-in-public]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Tue, 31 Oct 2023 01:22:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1698702193870/4ebdd4a4-fbf0-48a9-8846-8bc1c6a6297c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As October 2023 winds down, I can't help but think about all the wild stuff that went down in the tenth month of this epic year!</p>
<p>This was the month I spoke at DevFest in my local city on one of the dearest topics to my soul: developer relations.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698714114626/ba761613-b4d6-4439-ae24-173f5e06b982.png" alt class="image--center mx-auto" /></p>
<p>This was the month I moderated/hosted my first in-person technical-focused event.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698714295994/f7b561aa-061e-48be-afa2-479fdbccf3f4.png" alt class="image--center mx-auto" /></p>
<p>This was the month I connected with super amazing folks and got some inner referrals for some raging wild stuff. This was the month I intensified my learning-in-public strategy. This was the month I started my coffee chat series and already connected with <a target="_blank" href="https://hashnode.com/post/clod4bbgy000q09la734001dx">Cynthia</a> and Thembile.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698679871725/aaf33ff7-c4c5-478a-8702-98d4cb84eefb.png?auto=compress,format&amp;format=webp" alt /></p>
<p>This was the month I crossed the T's on my degree program. This was the month I relaunched my <a target="_blank" href="https://www.youtube.com/channel/UC7-Zub9gIa3iZby6stMY-Ww">YouTube</a> journey. This was the month I completed <a target="_blank" href="https://www.linkedin.com/posts/kohasummons_koha-has-completed-hacktoberfest-activity-7121786195696611328-QGhm?utm_source=share&amp;utm_medium=member_desktop">Hacktoberfest</a> and got a tree planted in my name.</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/M1HZrO2onV0?si=ft6JMzCFwEUm1orL">https://youtu.be/M1HZrO2onV0?si=ft6JMzCFwEUm1orL</a></div>
<p> </p>
<p>This was the month I realised that it's been a long time coming and every little step has unfolded up to this moment.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698714714524/1669685e-8943-42e4-9394-fe7fade88392.png" alt class="image--center mx-auto" /></p>
<p>There is still much work to be done and here's me saying to the koha that reads this sometime in the future: "You can always do more. Never lose sight of the goal - to create value and drive impact"</p>
<p>Love, Your friendly Neighbourhood DevRel 🥑 who Jams to <a target="_blank" href="https://www.youtube.com/watch?v=b2vUtCqdVcg">Lady Donli</a></p>
]]></content:encoded></item><item><title><![CDATA[Coffee with Cynthia Iradukunda]]></title><description><![CDATA[Coffee chats are awesome and I can't recommend them enough. I just had the opportunity to share one with Cynthia Iradukunda and the experience was a blast.]]></description><link>https://koha.hashnode.dev/coffee-with-cynthia-iradukunda</link><guid isPermaLink="true">https://koha.hashnode.dev/coffee-with-cynthia-iradukunda</guid><category><![CDATA[Developer]]></category><category><![CDATA[DevRel]]></category><category><![CDATA[coffee-chat]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Mon, 30 Oct 2023 16:32:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1698681219852/99e564ef-1672-4dfa-99b2-b226aadf6024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Coffee chats are awesome and I can't recommend them enough. I just had the opportunity to share one with Cynthia Iradukunda and the experience was a blast.</p>
<p><a target="_blank" href="https://www.linkedin.com/in/ciradu2204/">Cynthia</a> recently drew on her superhuman strength to kickstart the AWS User Group in Kigali and that's impressive knowing the struggles that come with breaking ground with a new, fresh and shining community.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698679871725/aaf33ff7-c4c5-478a-8702-98d4cb84eefb.png" alt class="image--center mx-auto" /></p>
<p>I should also add that she is also not new to doing cool stuff - as a GDSC Lead Alumni, WTM ambassador and a software engineer, she has experience pulling up feats that make folks go "ouuuuuuuuu".  </p>
<p>Our conversation touched on several things but notably was the discussion on how I can collaborate and support the User Group. We kinda found a suitable session I can pick up and I look forward to sharing that with the wonderful people of the AWS User group, Kigali.  </p>
<p>Love,</p>
<p>Your Friendly Neighbourhood DevRel🥑 who adores coffee,</p>
<p>Koha</p>
]]></content:encoded></item><item><title><![CDATA[How to make your Smart Contract ABI more Human]]></title><description><![CDATA[The Application Binary Interface(ABI) allow us to talk to smart contracts on the blockchain or call contract from our Decentralised Applications(dApp). It…]]></description><link>https://koha.hashnode.dev/how-to-make-your-smart-contract-abi-more-human</link><guid isPermaLink="true">https://koha.hashnode.dev/how-to-make-your-smart-contract-abi-more-human</guid><category><![CDATA[Web3]]></category><category><![CDATA[DX]]></category><category><![CDATA[Developer]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Tue, 20 Jun 2023 23:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1698990483768/639e3163-0f46-44ba-a331-23c725b5ab52.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The Application Binary Interface(ABI) allow us to talk to smart contracts on the blockchain or call contract from our Decentralised Applications(dApp).</p>
<p>It was necessary because applications outside the blockchain, or even other smart contracts, needed a way to communicate to contracts deployed to the blockchain. The ABI defines the specific methods, events, and errors that a smart contract has specified in its code.</p>
<p>However, ABI generated by tools like Hardhat/Truffle or by Remix—an IDE that allows you to write smart contracts in your browser, often lives in a JSON RPC file. If you look at this file right now, you will see several lines of code that might take you a while to understand, even though the machine understands.</p>
<p>So, Is it possible to have ABIs in a form that both the EVM and humans—well, developer humans, can understand? Yes, that's where the Human-readable ABI comes into play.</p>
<p>In this guide, you will write a simple, smart contract, compile it using Hardhat, and then generate a Human-readable ABI from the Smart contracts <a target="_blank" href="https://docs.ethers.io/v5/api/utils/abi/formats/#abi-formats--solidity">Solidity JSON ABI</a>. First, let's understand what a Human-readable ABI is.</p>
<h1 id="heading-what-is-a-human-readable-abi">What is a Human-readable ABI?</h1>
<p>The <a target="_blank" href="https://docs.ethers.io/v5/api/utils/abi/formats/#abi-formats--human-readable-abi">Human-readable AB</a>I is a format of the ABI that allows methods, events, and errors in smart contracts to be described using the properties they possess. Properties like name, type, inputs, outputs, etc. These properties are called Solidity Signatures.</p>
<p>It is important to note that a Solidity signature fully describes all the properties the ABI requires and is defined by the following:</p>
<ul>
<li><p>name</p>
</li>
<li><p>type (constructor, event, function)</p>
</li>
<li><p>inputs (types, nested structures, and optionally names)</p>
</li>
<li><p>outputs (types nested structures and optionally names)</p>
</li>
<li><p>state mutability (for constructors and methods)</p>
</li>
<li><p>payability (for constructors and methods)</p>
</li>
<li><p>whether inputs are indexed (for events)</p>
</li>
</ul>
<p>Human-readable ABI is a simple format. Machines can parse it. Humans can understand it. This makes it easy to write and use in your code, improving its readability.</p>
<p>If that isn't enticing enough, here's another cool benefit: when human-readable ABI is compared with the standard solidity ABI, it is considerably smaller, and this helps to trim your codebase extra fat.</p>
<p>And that's a good thing, whichever way you think about it.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ol>
<li><p>Nodejs - You can download the latest version at the <a target="_blank" href="https://nodejs.org/en/download/">Node Js Website</a>.</p>
</li>
<li><p>Hardhat - This tool makes testing, writing, deploying, and debugging smart contracts for DApps easy.</p>
</li>
<li><p>Visual Studio Code (VScode)- An Integrated Development Environment (IDE) that offers features like syntax highlighting and autocompletion for your code. You don't have to install VScode if you already have an IDE installed. This is just my preference.</p>
</li>
<li><p>Basic Javascript Knowledge</p>
</li>
</ol>
<h2 id="heading-setting-up-project">Setting up project</h2>
<p>To get started, open your terminal in any folder of your choice and run</p>
<pre><code class="lang-bash">mkdir human-readable-abi
</code></pre>
<p>This will create a new folder inside the folder you used to open the terminal and give it the name <code>human-readable-abi</code> .</p>
<p>Next, you need to initialize a <code>package.json</code> file inside your project. To do that, run:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> human-readable-abi
npm init -y
</code></pre>
<p>That will navigate into the <code>human-readable-abi</code> folder and then initialize a node project. Also, selecting default options for the project.</p>
<p>Now you can install packages you need to write your smart contracts.</p>
<p>You will need <em>Hardhat</em>, so run this command to install Hardhat in your project:</p>
<pre><code class="lang-bash">npm install --save-dev hardhat
</code></pre>
<p>If you use yarn, run the code below instead</p>
<pre><code class="lang-bash">yarn add hardhat
</code></pre>
<p>When that is done, if you go to your <code>package.json</code> File, you should see Hardhat listed as a dependency. Great, let's create a hardhat project and write your smart contract.</p>
<h3 id="heading-initializing-a-hardhat-project">Initializing a hardhat project</h3>
<p>Initialize a new hardhat project:</p>
<pre><code class="lang-bash">npx hardhat
</code></pre>
<p>When prompted to choose a project type, Select <code>Create an empty hardhat.config.js</code></p>
<pre><code class="lang-bash">$ npx hardhat
888    888                      888 888               888
888    888                      888 888               888
888    888                      888 888               888
8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888
888    888     <span class="hljs-string">"88b 888P"</span>  d88<span class="hljs-string">" 888 888 "</span>88b     <span class="hljs-string">"88b 888
888    888 .d888888 888    888  888 888  888 .d888888 888
888    888 888  888 888    Y88b 888 888  888 888  888 Y88b.
888    888 "</span>Y888888 888     <span class="hljs-string">"Y88888 888  888 "</span>Y888888  <span class="hljs-string">"Y888

👷 Welcome to Hardhat v2.9.9 👷‍

? What do you want to do? …
  Create a JavaScript project
  Create a TypeScript project
❯ Create an empty hardhat.config.js
  Quit</span>
</code></pre>
<h2 id="heading-writing-smart-contract">Writing smart contract</h2>
<p>Start by creating a new directory called contracts and create a file inside the directory called. <code>HelloWorld.sol</code>.</p>
<p>Paste the code below into the file and take a minute to read the code.</p>
<pre><code class="lang-c++"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
pragma solidity ^<span class="hljs-number">0.8</span><span class="hljs-number">.9</span>;

contract HelloWorld {

    <span class="hljs-comment">//events</span>
    <span class="hljs-function">event <span class="hljs-title">UpdatedMessages</span><span class="hljs-params">(<span class="hljs-built_in">string</span> oldStr, <span class="hljs-built_in">string</span> newStr)</span></span>;
    <span class="hljs-function">event <span class="hljs-title">OwnershipTransferred</span><span class="hljs-params">(address indexed oldOwner, address indexed newOwner)</span></span>;

    <span class="hljs-comment">///You cannot do that</span>
    <span class="hljs-function">error <span class="hljs-title">Unauthorized</span><span class="hljs-params">()</span></span>;

    <span class="hljs-comment">// state variable, would be stored permanently on the blockchain</span>
    <span class="hljs-built_in">string</span> <span class="hljs-keyword">public</span> message;
    address owner;

    mapping (uint =&gt; address) <span class="hljs-keyword">public</span> ownersList;
    uint <span class="hljs-keyword">public</span> ownersCount;

    <span class="hljs-keyword">enum</span> dummyEnum {name,age}

    <span class="hljs-comment">// a modifier to prevent function calls</span>
    <span class="hljs-comment">// from unauthorized actors</span>
    modifier onlyOwner{
        <span class="hljs-keyword">if</span>(msg.sender != owner) <span class="hljs-function">revert <span class="hljs-title">Unauthorized</span><span class="hljs-params">()</span></span>;
        _;
    }

    <span class="hljs-comment">// allow the contract to be called with a setup value </span>
    <span class="hljs-comment">// in this case pass initMessage to message(state var)</span>
    constructor (<span class="hljs-built_in">string</span> memory initMessage) {
        message = initMessage;
        owner = msg.sender;
        ownersCount = <span class="hljs-number">1</span>;
        ownersList[ownersCount] = owner;
    }

    <span class="hljs-function">function <span class="hljs-title">update</span><span class="hljs-params">(<span class="hljs-built_in">string</span> memory newMessage)</span> <span class="hljs-keyword">public</span> </span>{
        <span class="hljs-built_in">string</span> memory oldMsg = message;
        message = newMessage;
        <span class="hljs-function">emit <span class="hljs-title">UpdatedMessages</span><span class="hljs-params">(oldMsg, newMessage)</span></span>;
    }

    <span class="hljs-function">function <span class="hljs-title">transferOwnership</span><span class="hljs-params">(address _newOwner)</span> <span class="hljs-keyword">public</span> onlyOwner <span class="hljs-title">returns</span><span class="hljs-params">(<span class="hljs-keyword">bool</span> success)</span></span>{
        owner = _newOwner;
        ownersCount++;
        ownersList[ownersCount] = _newOwner;
        <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
    }
}
</code></pre>
<p>This is a simple smart contract that has a state variable <code>message</code>, a constructor to initialize the <code>message</code> when the contract is deployed, and an <code>update</code> function to modify the <code>message</code> variable.</p>
<p>An event is also defined that would be emitted whenever the <code>update</code> function is called. Let's add a few features to the smart contract before we compile it.</p>
<p>The <code>transferOwnership</code> function would transfer contract ownership to a new address. There is a <a target="_blank" href="https://koha.hashnode.dev/function-modifiers-in-solidity">modifier</a> <code>onlyOwner</code> that prevents unauthorized calls to <code>transferOwnership</code>.</p>
<p><code>ownersList</code> Mapping keeps a list of the previous and current owners of the smart contract. <code>ownersCount</code> is an integer that tracks how many owners there are. The <code>dummyEnum</code> is simply presentational, so it does nothing. We included it to see what the Human-readable ABI format looks like with enums.</p>
<p><code>error Unauthorized();</code> It is a custom error that we can use to inform whoever or whatever consumes our contract that they are not permitted to call the <code>transferOwnership</code> function if they do not own the agreement.</p>
<p>At this stage, we can go ahead and compile your smart contracts.</p>
<h2 id="heading-compiling-smart-contract">Compiling Smart Contract</h2>
<p>We need to compile our smart contract into a form the EVM can understand. To compile the contract, run <code>npx hardhat compile</code> it in your terminal. The compile task is one of Hardhat's built-in tasks.</p>
<p>This will compile your code and generate an ABI file for your smart contract. The default location for the ABI JSON is inside the <code>artifacts\contracts\HelloWorld.sol</code> folder.</p>
<p>Navigate to that folder and open the <code>HelloWorld.json</code>. It should look like this:</p>
<pre><code class="lang-json">{
  <span class="hljs-attr">"_format"</span>: <span class="hljs-string">"hh-sol-artifact-1"</span>,
  <span class="hljs-attr">"contractName"</span>: <span class="hljs-string">"HelloWorld"</span>,
  <span class="hljs-attr">"sourceName"</span>: <span class="hljs-string">"contracts/HelloWorld.sol"</span>,
  <span class="hljs-attr">"abi"</span>: [
    {
      <span class="hljs-attr">"inputs"</span>: [
        {
          <span class="hljs-attr">"internalType"</span>: <span class="hljs-string">"string"</span>,
          <span class="hljs-attr">"name"</span>: <span class="hljs-string">"initMessage"</span>,
          <span class="hljs-attr">"type"</span>: <span class="hljs-string">"string"</span>
        }
      ],
      <span class="hljs-attr">"stateMutability"</span>: <span class="hljs-string">"nonpayable"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"constructor"</span>
    },
    {
      <span class="hljs-attr">"inputs"</span>: [],
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Unauthorized"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"error"</span>
    },
...
<span class="hljs-comment">// even more lines of JSON code</span>
</code></pre>
<p>Awesome! You have just generated an ABI for your smart contract. With this, you can write DAPPs to talk to your smart contract once you deploy it on the blockchain. Let's go ahead and convert that to a human-readable ABI.</p>
<h2 id="heading-generating-human-readable-abis">Generating Human-readable ABIs</h2>
<p>First, I will show you how to generate the Human-readable ABI using a custom generator script then, we will use a simple tool I built, <a target="_blank" href="https://kohasummons.github.io/humanizer">Humanizer</a>, to accomplish the same thing.</p>
<h2 id="heading-writing-a-generator-script">Writing a Generator script</h2>
<p>Create a new file inside your scripts folder named. <code>ABIconverter.js</code>.</p>
<p>We would need <code>ethers.js</code>, a library that helps us interact with the blockchain. Thankfully, Hardhat comes with a copy of <code>ethers.js</code> out of the box, so we don't need to install it explicitly.</p>
<p>Let's import Hardhat inside <code>ABIconverter.js</code></p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> hre = <span class="hljs-built_in">require</span>(<span class="hljs-string">'hardhat'</span>);
</code></pre>
<p>Inside the file, you need to import your <code>HelloWorld</code> JSON ABI. Here's how you will do that:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> helloWorld = <span class="hljs-built_in">require</span>(<span class="hljs-string">"./artifacts/contracts/HelloWorld.sol/HelloWorld.json"</span>);
</code></pre>
<p>After the import, here comes the actual conversion part; add the following code to the rest of the code:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> helloWorld = <span class="hljs-keyword">new</span> hre.ethers.utils.Interface(helloWorldJson.abi);
<span class="hljs-keyword">const</span> { full, minimal } = hre.ethers.utils.FormatTypes;

<span class="hljs-comment">// `full` </span>
<span class="hljs-keyword">const</span> HelloWorld = helloWorld.format(full);

<span class="hljs-comment">// Replace `full` with `minimal` to reduce the ABI further.</span>
<span class="hljs-comment">// const HelloWorld = helloWorld.format(minimal);</span>


<span class="hljs-built_in">console</span>.log(HelloWorld);
</code></pre>
<p>The <code>new hre.ethers.utils.Interface</code> will create an interface using the <code>ABI</code> inside our <code>helloworld</code> import. <code>helloWorld.format</code> applies a format to the interface. You can decide between the <code>full</code> or <code>minimal</code> format types.</p>
<p>There is a subtle difference between the two formats; you can read it up at the <a target="_blank" href="https://docs.ethers.io/v5/api/utils/abi/formats/#abi-formats--solidity">ethers docs</a></p>
<p>Finally, we log the Human-readable ABI to the console. To test our script, go to your terminal and run</p>
<pre><code class="lang-js">node scripts/ABIconverter.js
</code></pre>
<p>You should see your Human-readable ABI printed on your console. It should look like this:</p>
<pre><code class="lang-js">[
  <span class="hljs-string">'constructor(string initMessage)'</span>,
  <span class="hljs-string">'error Unauthorized()'</span>,
  <span class="hljs-string">'event OwnershipTransferred(address indexed oldOwner, address indexed newOwner)'</span>,
  <span class="hljs-string">'event UpdatedMessages(string oldStr, string newStr)'</span>,
  <span class="hljs-string">'function message() view returns (string)'</span>,
  <span class="hljs-string">'function ownersCount() view returns (uint256)'</span>,
  <span class="hljs-string">'function ownersList(uint256) view returns (address)'</span>,
  <span class="hljs-string">'function transferOwnership(address _newOwner) returns (bool success)'</span>,
  <span class="hljs-string">'function update(string newMessage)'</span>
]
</code></pre>
<p>Great Job! You just took an almost unreadable form of ABI and turned it into something you can understand. Even crazier, the EVM can understand too.</p>
<p>With this form, you can see all the functions, events, and other signatures provided by your <code>HelloWorld</code> smart contract, and to top it all, you can also know the type and name of the argument they need. This is way better than that chunk of hideous ABI you used before, right?</p>
<p>There is another way to generate Human-readable ABI. I dare say it's way easier and could make your workflow faster.</p>
<h2 id="heading-using-the-humanizer-tool">Using the Humanizer tool</h2>
<p><a target="_blank" href="https://kohasummons.github.io/humanizer">Humanizer</a> is a tool that converts JSON ABI to Human-readable ABIs — all in three clicks. Humanizer can compile your ABI whether you compiled it with Hardhat or wrote the code in Remix.</p>
<p>To use Humanizer, follow the steps described below.</p>
<p>Step 1: Open the <code>HelloWorld.json</code> ABI file. You should find it in <code>./artifacts/contracts/HelloWorld.sol/HelloWorld.json</code></p>
<p>Step 2: Copy the contents of the file, i.e., the entire <code>HelloWorld.json</code> content</p>
<p>Step 3: Open your browser and go to <a target="_blank" href="https://kohasummons.github.io/humanizer">https://kohasummons.github.io/humanizer</a></p>
<p>Step 4: Paste the JSON you copied inside Humanizer's code editor</p>
<p>Step 5: Select a format type, <em>Full</em> or <em>Minimal</em></p>
<p>Step 6: Click Generate and then copy the transformed ABI.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1661165074088/pZ-LmulWp.gif" alt="Generating Human-readable ABI with humanizer.gif" /></p>
<p>That's how simple it is to convert your JSON ABI to Human-readable ABI. You can support Humanizer by giving the project a star <a target="_blank" href="https://github.com/kohasummons/humanizer">on GitHub</a></p>
<h1 id="heading-how-to-use-the-human-readable-abi">How to use the Human-readable ABI</h1>
<p>To use the ABI we generated, create a new file called <code>contracts.js</code> in the root of your app project.</p>
<pre><code class="lang-bash">touch contracts.js
</code></pre>
<p>Paste the Human-readable ABI code inside <code>contracts.js</code>. Now all you need to do is import the ABI wherever you need to create a call to the smart contract.</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { HelloWorld } <span class="hljs-keyword">from</span> <span class="hljs-string">"./contracts.js"</span>
<span class="hljs-keyword">import</span> { ethers } <span class="hljs-keyword">from</span> <span class="hljs-string">"ethers.js"</span>

<span class="hljs-keyword">const</span> { ethereum } = <span class="hljs-built_in">window</span>;
<span class="hljs-keyword">const</span> provider = <span class="hljs-keyword">new</span> ethers.providers.Web3Provider(ethereum);
<span class="hljs-keyword">const</span> signer = provider.getSigner();

<span class="hljs-comment">// HelloWorld_Contract_Address - Address where contract was deployed to</span>
<span class="hljs-keyword">const</span> HelloWorld = <span class="hljs-keyword">new</span> ethers.Contract(
    HelloWorld_Contract_Address,
    HelloWorld,
    signer
);

<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">await</span> HelloWorld.ownersCount());
</code></pre>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Human-readable ABIs improve your code in two significant ways:</p>
<ol>
<li><p>Your code instantly becomes more readable,</p>
</li>
<li><p>You cut out code fat. Two of the most beautiful things you can wish for as a developer.</p>
</li>
</ol>
<p>Now you can go out there and improve your developer experience. Thank you for reading this article. If you found value from it please do like, share and leave a comment.</p>
]]></content:encoded></item><item><title><![CDATA[Fix this Git error: src refspec main does not match any]]></title><description><![CDATA[When I start a new project, one of the first things I do is upload it to Github. The flow typically entails creating a GitHub repo, initializing Git in my…]]></description><link>https://koha.hashnode.dev/fix-this-git-error-src-refspec-main-does-not-match-any</link><guid isPermaLink="true">https://koha.hashnode.dev/fix-this-git-error-src-refspec-main-does-not-match-any</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Wed, 01 Feb 2023 08:04:10 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1675238191955/71ae378c-643f-4492-89e0-09ae11c4b9ac.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When I start a new project, one of the first things I do is upload it to Github. The flow typically entails creating a GitHub repo, initializing Git in my local repo, and configuring the remote repo origin, yidi yidi yadah.</p>
<p>However, recently, running into the <code>src refspec main does not match any</code> error while setting up a Nuxt project taught me something new: you can't push a project with no commit history to remote.</p>
<p>The way Git calls your attention to that is by slapping you across the face with an error like this:</p>
<pre><code class="lang-bash">error: src refspec main does not match any
failed to push some refs to <span class="hljs-string">'https://github.com/kohasummons/molar-nuxt.git'</span>
</code></pre>
<p>In this short, snappy article, I will show you why it happens, how I fixed it, and something important to remember before pushing code to any remote repository.</p>
<h2 id="heading-the-error-happens-for-a-reason">The Error happens for a reason</h2>
<p>When you initialize Git in a new project, you have zero commits. To commit a file, you make changes to the file, add it to the staging area, then, at that point, you commit the file. Once you create a commit, you can push it to any remote server.</p>
<p>If you skip the part where you create a commit and you go ahead to push your empty-commit-history code to a remote repository, Git will definitely slap you with this error.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675238078681/1a9ebf50-b507-4547-a845-0f636e8483ec.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-fix-the-error">Fix the Error</h2>
<p>Git throws this error because It wants you to make at least a single commit so it knows what changes to make to the remote repository. Anytime you come to get this error, check to see if you have an empty commit history. If yes, make some commitzzzzz.</p>
<p>This is one of several reasons why you might encounter this error. At least, in my own case, this is what happened. Now, I know not to do that. Hopefully, so do you!</p>
<p>I will leave links to other articles that address the <code>src refspec main does not match any</code> error in the resources channel. Take a look sometime.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>If you try to push a code to a remote repository without having at least a single commit history, you will run into the <code>src refspec main does not match any</code> error. A simple way to solve this error is to create a commit at least once before you push the code to any remote repo.</p>
<p>If this was helpful, please share it with a friend!</p>
<h2 id="heading-resources">Resources</h2>
<ol>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/error-src-refspec-master-does-not-match-any-how-to-fix-in-git/">Error: src refspec master does not match any – How to Fix in Git (</a><a target="_blank" href="http://freecodecamp.org">freecodecamp.org</a><a target="_blank" href="https://www.freecodecamp.org/news/error-src-refspec-master-does-not-match-any-how-to-fix-in-git/">)</a></p>
</li>
<li><p><a target="_blank" href="https://www.baeldung.com/java-git-src-refspec-match">The Problem With ‘src refspec does not match any’ | Baeldung</a></p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[#001: I got into DxMentorship.]]></title><description><![CDATA[[Note: I wrote this in 2022 when I got the news that I was selected for the program. Posting in 2023 cause I'm cleansing my draft] What would it feel like…]]></description><link>https://koha.hashnode.dev/into-dxmentorship</link><guid isPermaLink="true">https://koha.hashnode.dev/into-dxmentorship</guid><category><![CDATA[DevRel]]></category><dc:creator><![CDATA[Joshua Omobola]]></dc:creator><pubDate>Thu, 01 Dec 2022 20:10:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1678910760424/db09d0e5-829d-4c87-a2cb-cc7760d0ba7b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>[Note: I wrote this in 2022 when I got the news that I was selected for the program. Posting in 2023 cause I'm cleansing my draft]</p>
<p>What would it feel like if, for 12 weeks, you got to learn from a superhuman the exact things you need to meet your goals? I know this might sound fictitious, but that is exactly what I feel right now. The rush. The thumping of excitement. And it all started with a mail.</p>
<p><img src="https://media.giphy.com/media/mXOidJUQICXXw08bCf/giphy.gif" alt="kanye beans" /></p>
<p>I got into dxMentorship. I. GOT. IN!</p>
<p><img src="https://media.giphy.com/media/FDSINN4OPTHmGytYK6/giphy.gif" alt="Away" /></p>
<p>And in the next 12 weeks, I would be grooming myself up to stomp into the DevRel scene(hahaha).</p>
]]></content:encoded></item></channel></rss>