<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Darlington Gospel</title>
    <description>The latest articles on DEV Community by Darlington Gospel (@daltonic).</description>
    <link>https://dev.to/daltonic</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F565243%2F2e6de20a-5fc3-4512-bd44-dfa9d1dfca68.png</url>
      <title>DEV Community: Darlington Gospel</title>
      <link>https://dev.to/daltonic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/daltonic"/>
    <language>en</language>
    <item>
      <title>How I Would Design an Autonomous REIT that Pays Monthly Dividends</title>
      <dc:creator>Darlington Gospel</dc:creator>
      <pubDate>Thu, 26 Mar 2026 05:45:34 +0000</pubDate>
      <link>https://dev.to/daltonic/how-i-would-design-an-autonomous-reit-that-pays-monthly-dividends-3ngg</link>
      <guid>https://dev.to/daltonic/how-i-would-design-an-autonomous-reit-that-pays-monthly-dividends-3ngg</guid>
      <description>&lt;p&gt;Most real estate investment trusts still run leasing and dividends through spreadsheets and human teams. They think the problem is slow paperwork or high fees.&lt;br&gt;
It is not.&lt;/p&gt;

&lt;p&gt;The real gap is blockchain underuse. REIT operators use less than 5% of what blockchain can do for trust and instant settlement. That is not a property management problem. It is a trust and latency problem — and no traditional process upgrade fixes an on-chain settlement problem.&lt;/p&gt;

&lt;p&gt;Here is the system I would build to close that gap completely: a closed-loop, 7-layer autonomous AI + blockchain + automation operating system on &lt;a href="https://polygon.technology/" rel="noopener noreferrer"&gt;Polygon PoS&lt;/a&gt; that executes the entire REIT lifecycle without intermediaries and pays monthly dividends in under 15 seconds.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhsva56ub6n30mr2pdhiv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhsva56ub6n30mr2pdhiv.png" alt="Reita v1.3 — full 7-layer architecture across 24 nodes on Polygon PoS. Data flows upward from L01 (Data &amp;amp; Ingestion) through L02 (AI &amp;amp; Intelligence) and downward to L03 (Blockchain &amp;amp; Trust). The Automation Fabric (L04) connects AI decisions to on-chain settlement. L05 (Interface &amp;amp; UX), L06 (Infra &amp;amp; Observability), and L07 (Payments &amp;amp; Finance) complete the closed loop — every arrow represents an event-driven dependency, not a manual handoff."&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  The Infrastructure Problem
&lt;/h2&gt;

&lt;p&gt;Traditional REITs have three compounding failures. Manual underwriting takes weeks. Leases need lawyers and paper signatures. Rent collection sits in spreadsheets, and dividends arrive quarterly after wire fees and delays. That costs time, errors, and lost yield — and none of it is a technology limitation. It is a stack design failure.&lt;/p&gt;

&lt;p&gt;The deeper issue is coordination trust. When a lease gets executed today, the proof lives in a filing cabinet or a PDF on a shared drive. When rent is collected, the confirmation travels through a bank, a property manager, an accountant, and a wire transfer that takes days to clear. Each handoff is a point where data can be disputed, delayed, or manipulated. The entire system is held together by human intermediaries because no one built the infrastructure that makes intermediaries unnecessary.&lt;/p&gt;

&lt;p&gt;Blockchain is the obvious fix — except most REIT operators have never built it in properly. They bolt on a token here, a &lt;a href="https://ethereum.org/en/smart-contracts/" rel="noopener noreferrer"&gt;smart contract&lt;/a&gt; there, and call it "tokenized real estate." What they actually have is a traditional REIT with a digital wrapper. The operational logic — the leasing, the rent cycles, the dividend calculations — still runs on the same human-dependent stack underneath.&lt;/p&gt;

&lt;p&gt;The fix is not a token. The fix is redesigning the operating system from the ground up so that trust, settlement, and decision-making are all encoded in the infrastructure itself.&lt;/p&gt;


&lt;h2&gt;
  
  
  The System Architecture: 7-Layer Autonomous REIT Operating System
&lt;/h2&gt;

&lt;p&gt;The architecture organises 24 nodes across 7 horizontal layers. Data flows upward from ingestion to intelligence. Decisions flow downward to blockchain settlement. The Automation Fabric connects everything. No layer has a dependency that skips a layer below it.&lt;/p&gt;

&lt;p&gt;You can watch the full step-by-step breakdown of the architecture and user journey in the video below, or &lt;a href="https://www.youtube.com/playlist?list=PLUDcVqFK2t-B1i57WTKABR0S48rnUv3Lw" rel="noopener noreferrer"&gt;&lt;strong&gt;explore the full playlist covering different system architectures&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/L7RjU09dvj0"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Here is what each layer does and why it exists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L01 — Data &amp;amp; Ingestion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbx0h082rykt4pp90fwru.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbx0h082rykt4pp90fwru.png" alt="Layer 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the sensory layer. Four nodes handle everything that enters the system: IoT telemetry from property sensors (pushed via MQTT at 1 Hz, normalised into typed events on &lt;code&gt;Kafka&lt;/code&gt;), the &lt;code&gt;PGVector RAG Store&lt;/code&gt; (a PostgreSQL 16 + &lt;a href="https://github.com/pgvector/pgvector" rel="noopener noreferrer"&gt;PGVector&lt;/a&gt; instance holding SEC regulations, lease templates, MLS comparables, and REIT tax rules as searchable vector embeddings), &lt;code&gt;The Graph Subgraph&lt;/code&gt; (which indexes all smart contract events on Polygon PoS and exposes a GraphQL API returning portfolio balances in under 200ms), and &lt;code&gt;IPFS +&lt;/code&gt; &lt;a href="https://www.pinata.cloud/" rel="noopener noreferrer"&gt;Pinata&lt;/a&gt; (decentralised document storage where every lease PDF, property deed, and inspection report is pinned, with a content identifier written on-chain as an immutable reference).&lt;/p&gt;

&lt;p&gt;L01 solves the data silo problem that breaks traditional REITs. Every agent in L02 operates from a single, queryable source of truth — not from a spreadsheet someone last updated on Tuesday.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L02 — AI &amp;amp; Intelligence&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4g6885hjd0ywmmk209jq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4g6885hjd0ywmmk209jq.png" alt="Layer 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Seven &lt;a href="https://www.langchain.com/langgraph" rel="noopener noreferrer"&gt;LangGraph&lt;/a&gt; agents run here. Each agent has a defined persona, a constrained toolset, a versioned prompt library, and a deterministic output schema validated by &lt;a href="https://docs.pydantic.dev/" rel="noopener noreferrer"&gt;Pydantic&lt;/a&gt;. They share no state at runtime. All context is injected via a structured Context Envelope assembled in under 250ms.&lt;/p&gt;

&lt;p&gt;The roster: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Investor Advisor&lt;/strong&gt; generates personalised allocation recommendations. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Acquisition Scout&lt;/strong&gt; runs on Grok-4 via Groq (under 900ms) and scores deals autonomously against cap rate, cash-on-cash return, and vacancy risk — submitting letters of intent on properties under $2M without human approval. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tenant Matcher&lt;/strong&gt; sets rent within DAO-approved bands, screens tenants for Fair Housing Act compliance, and approves leases in under 12 seconds. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Operations Overseer&lt;/strong&gt; dispatches maintenance contractors using GPT-4o Vision to verify work completion before releasing payment. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Financial Steward&lt;/strong&gt; pulls all expense records, reconciles against collected rent, and calculates net distributable income. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compliance Warden&lt;/strong&gt; monitors five REIT qualification tests daily and issues on-chain attestations. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Supervisor Agent&lt;/strong&gt; coordinates all other agents, arbitrates conflicts, and routes anomalies to the human escalation queue.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The business logic here: no human approval delay in the critical path. Decisions drop straight to the blockchain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L03 — Blockchain &amp;amp; Trust&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhbj6wwvb38if5jppocx8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhbj6wwvb38if5jppocx8.png" alt="Layer 3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This layer is the legal spine. Four smart contracts on Polygon PoS encode everything that would otherwise live in a law firm's filing cabinet.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ReitaPropertyNFT.sol&lt;/code&gt; &lt;strong&gt;(ERC-721)&lt;/strong&gt; is the on-chain property title deed — soulbound to the Reita operations multisig, minted at acquisition close, with the &lt;a href="https://ipfs.tech/" rel="noopener noreferrer"&gt;IPFS&lt;/a&gt; deed CID embedded in token metadata. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;FractionalShareContract.sol&lt;/code&gt; &lt;strong&gt;(ERC-1155)&lt;/strong&gt; represents divisible investor shares. &lt;code&gt;balanceOf()&lt;/code&gt; is used for real-time dividend calculation. Every secondary transfer is tracked on-chain at 0.3% fee. &lt;code&gt;RentEscrowContract.sol&lt;/code&gt; is the neutral vault that receives &lt;a href="https://www.circle.com/usdc" rel="noopener noreferrer"&gt;USDC&lt;/a&gt; rent, holds security deposits, and enforces a 48-hour dispute window before releasing funds. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;DividendDistributor.sol&lt;/code&gt; is the gas-optimised batch payout contract that distributes pro-rata rental income to all fractional shareholders on Polygon PoS — 5-second finality means investors see USDC in their wallets within 15 seconds of the distribution call.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where the blockchain underuse problem ends. No spreadsheets. No intermediaries. The contract &lt;em&gt;is&lt;/em&gt; the law.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L04 — Automation Fabric&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyjdgizmyui6h3k0e37gz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyjdgizmyui6h3k0e37gz.png" alt="Layer 4"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This layer is what prevents the system from collapsing under its own complexity. The runtime is &lt;a href="https://temporal.io/" rel="noopener noreferrer"&gt;Temporal.io&lt;/a&gt; — durable, exactly-once workflow execution with automatic replay on failure. For a system managing financial assets, this is non-negotiable. No workflow ever silently fails.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;Kafka Event Bus&lt;/code&gt; carries every platform domain event, partitioned by &lt;code&gt;property_id&lt;/code&gt; for ordered processing. &lt;a href="https://keda.sh/" rel="noopener noreferrer"&gt;KEDA&lt;/a&gt; autoscales AI agent pods based on &lt;a href="https://kafka.apache.org/" rel="noopener noreferrer"&gt;Kafka&lt;/a&gt; consumer lag — during a major rent collection event, agent pods scale up automatically. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;Acquisition Workflow&lt;/strong&gt; manages the full lifecycle from deal identification to token issuance, with saga compensation logic: if &lt;code&gt;registerProperty()&lt;/code&gt; fails, all prior steps reverse — no property is ever left in a half-registered state. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;Rental Lifecycle Workflow&lt;/strong&gt; manages 10,000+ concurrent tenancy instances, each tracking its own schedule, state, and exception handling via Temporal's persistence engine.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;L04 connects AI decisions to blockchain actions. No dropped steps, no race conditions, no missing state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L05 — Interface &amp;amp; UX&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzzxoapfzkbf4ard5y4ah.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzzxoapfzkbf4ard5y4ah.png" alt="Layer 5"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This layer serves the humans. Four surfaces, all built on &lt;code&gt;Next.js 15&lt;/code&gt; with real-time data via &lt;a href="https://thegraph.com/" rel="noopener noreferrer"&gt;The Graph&lt;/a&gt; and &lt;code&gt;Socket.io&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Listing Syndication&lt;/strong&gt; automatically publishes vacant units to &lt;a href="https://www.zillow.com/" rel="noopener noreferrer"&gt;Zillow&lt;/a&gt;, Trulia, &lt;a href="https://www.redfin.com/" rel="noopener noreferrer"&gt;Redfin&lt;/a&gt;, and MLS the moment a property becomes available — and deactivates the listing the moment a lease is signed. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tenant Portal&lt;/strong&gt; handles the full application flow: browse listings, submit an encrypted application with &lt;a href="https://plaid.com/" rel="noopener noreferrer"&gt;Plaid&lt;/a&gt;-verified income, receive an AI decision in seconds, and e-sign a jurisdiction-specific lease directly in the browser. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Investor Dashboard&lt;/strong&gt; renders real-time yield curves, dividend history, and property NAV with on-chain portfolio balances via The Graph's GraphQL API. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Operator Dashboard&lt;/strong&gt; gives platform operators a unified view of every active lease, pending maintenance job, agent decision log, and compliance alert — updating via SSE at 500ms frequency.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;L06 — Infra &amp;amp; Observability&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fivzpunez9ggfs25de3es.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fivzpunez9ggfs25de3es.png" alt="Layer 6"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AWS EKS runs all pods. &lt;a href="https://prometheus.io/" rel="noopener noreferrer"&gt;Prometheus&lt;/a&gt; and &lt;a href="https://grafana.com/" rel="noopener noreferrer"&gt;Grafana&lt;/a&gt; handle metrics and alerting. &lt;a href="https://smith.langchain.com/" rel="noopener noreferrer"&gt;LangSmith&lt;/a&gt; traces every &lt;code&gt;LangGraph&lt;/code&gt; agent call — every prompt, response, token count, model version, and latency — giving a full audit trail for every autonomous decision. &lt;code&gt;KEDA&lt;/code&gt; autoscales AI agent replicas 1–20 based on Kafka consumer lag per topic. &lt;code&gt;AlertManager&lt;/code&gt; pages on-call engineers for SLA breaches: agent inference over 900ms, lease approval over 12 seconds, dividend distribution over 15 seconds.&lt;/p&gt;

&lt;p&gt;Without LangSmith tracing, a prompt regression causing discriminatory lease decisions would be invisible until a Fair Housing Act violation occurred. L06 is not optional infrastructure. It is a first-class architectural requirement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L07 — Payments &amp;amp; Finance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbrw9835t9a2zbvv30wps.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbrw9835t9a2zbvv30wps.png" alt="Layer 7"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Stripe ACH&lt;/code&gt; initiates monthly rent pulls from tenant bank accounts. Once USD clears, &lt;a href="https://www.circle.com/" rel="noopener noreferrer"&gt;Circle&lt;/a&gt; converts to USDC at 1:1 parity and routes to the &lt;code&gt;RentEscrowContract&lt;/code&gt; on Polygon PoS. Investors deposit USDC directly — gasless, via Circle's programmable wallets API. Dividend payouts flow through the &lt;code&gt;DividendDistributor&lt;/code&gt; contract. All payment webhook endpoints are idempotent — Stripe and Circle event IDs are stored in PostgreSQL with &lt;code&gt;ON CONFLICT DO NOTHING&lt;/code&gt;, so duplicate deliveries are silently discarded.&lt;/p&gt;

&lt;p&gt;L07 is intentionally isolated as its own layer because it sits at the intersection of traditional financial regulation and blockchain infrastructure. Swapping Stripe or Circle for a different provider never touches agent or workflow logic.&lt;/p&gt;

&lt;h2&gt;
  
  
  End-to-End System Flow Simplified
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Investment Entry&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Investor deposits &lt;strong&gt;USDC&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Corresponding &lt;strong&gt;shares are minted on-chain&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Property Acquisition&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Acquisition Scout&lt;/strong&gt; identifies a property&lt;/li&gt;
&lt;li&gt;Property is registered as an &lt;a href="https://eips.ethereum.org/EIPS/eip-721" rel="noopener noreferrer"&gt;&lt;strong&gt;ERC-721 NFT&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Tenant Onboarding&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tenant submits application&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tenant Matcher&lt;/strong&gt; reviews and approves &lt;em&gt;(&amp;lt; 12 seconds)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Rental Lifecycle Activation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Temporal Rental Lifecycle Workflow&lt;/strong&gt; is triggered&lt;/li&gt;
&lt;li&gt;Lease becomes active and managed automatically&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. Rent Collection &amp;amp; Conversion&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stripe ACH&lt;/strong&gt; pulls monthly rent (fiat)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Circle&lt;/strong&gt; converts fiat → &lt;strong&gt;USDC&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Funds are deposited into &lt;strong&gt;RentEscrow&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;6. Financial Reconciliation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Financial Steward&lt;/strong&gt; validates and reconciles all inflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;7. Investor Payout&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DividendDistributor&lt;/strong&gt; executes batch payouts &lt;em&gt;(&amp;lt; 15 seconds)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;8. Transparency &amp;amp; Reporting&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Investor Dashboard&lt;/strong&gt; updates&lt;/li&gt;
&lt;li&gt;On-chain receipt is recorded and visible&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5nbciqmw1x1qa3makqxs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5nbciqmw1x1qa3makqxs.png" alt="24-node dependency graph across 7 layers. The right-side legend shows seven distinct inter-layer connection types: L01 DATA → L02 AI (Kafka consumer streams and RAG retrieval), L02 AI → L03 CHAIN (smart contract calls via Temporal activities), L03 CHAIN → L01 INDEX (Alchemy webhook events triggering The Graph re-indexing), L04 AUTO → L02 AI (Temporal workflow invoking LangGraph agents), L04 AUTO → L03 CHAIN (Temporal activities calling contract methods directly), L07 FIN → L03 CHAIN (Circle USDC deposits to Rent Escrow), and L06 INFRA → L02 AI (system health metrics injected into Supervisor Agent context). The bottom ticker shows the live event sequence from investor deposit through dividend distribution."&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  User Experience — How Each Stakeholder Interacts
&lt;/h2&gt;

&lt;p&gt;Three user types interact with this system. Each one used to operate at the mercy of delays they couldn't see or control. Here is what changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Investors&lt;/strong&gt; previously waited months for quarterly dividends to arrive via wire transfer, with no real-time visibility into portfolio performance. In this system, an investor connects a wallet, deposits USDC, and immediately sees projected yield on the dashboard. Shares mint on-chain as ERC-1155 tokens pro-rata to their contribution. Every month, the Financial Steward reconciles income, the &lt;code&gt;DividendDistributor&lt;/code&gt; executes the payout, and the investor sees USDC land in their wallet — with a cryptographically verifiable on-chain receipt — within 15 seconds of distribution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tenants&lt;/strong&gt; used to fill out paper applications, wait for a human to review them, negotiate leases through a property manager, and sign documents through a multi-day back-and-forth. In this system, a tenant browses AI-curated listings on the portal or through a Zillow click-through, submits an encrypted application, receives an AI screening decision in seconds, and e-signs a fully customised jurisdiction-specific lease in the same browser session. The security deposit and first month's rent are collected once, automatically, at activation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operators&lt;/strong&gt; used to be the connective tissue holding the whole process together — coordinating between lawyers, accountants, property managers, and banks. In this system, the Operator Dashboard surfaces everything the Supervisor Agent has already handled: every active lease, every maintenance job, every compliance alert, every yield distribution. Human operators are present for escalations — not for routine execution. The system handles the critical path. The operator sets the policy parameters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feqtfg0yqgx0bpg37d2q8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feqtfg0yqgx0bpg37d2q8.png" alt="Journey Map Part 1 covers three phases: Investor Onboarding (Deposit USDC → Mint Shares via ERC-1155), Property Acquisition (Acquisition Scout autonomous deal scoring → Register Property as ERC-721 NFT on IPFS + Polygon PoS), and Tenant Discovery &amp;amp; Apply (Browse Listings via syndicated portal → Submit Application → Tenant Matcher initial screening with Fair/Instant approval tags). Four actor types are colour-coded throughout: Investor &amp;amp; Tenant (blue), AI Agents (yellow), Blockchain Layer (green), Finance &amp;amp; Escrow (red)."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second phase of the journey map shows what happens after the tenant is approved: lease generation, e-signature, escrow initiation, automated rent collection, Financial Steward reconciliation, dividend distribution, platform fee auto-deduction on-chain, and instant USDC payout to the Investor Dashboard. The entire sequence — phases 4 through 7 — runs without a single human step in the critical path.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9w57uhb4ouveogtw1fe0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9w57uhb4ouveogtw1fe0.png" alt="Journey Map Part 2 covers four phases: Tenant Screening &amp;amp; Lease (Generate Lease via AI-drafted → E-Sign Lease with CID anchored on-chain → Initiate Lease via RentEscrow), Lease Activation &amp;amp; Rent Cycle (Collect Rent via Stripe ACH + Temporal → Financial Steward reconciliation), Dividend Distribution (Distribute Dividends pro-rata via DividendDistributor → Platform Fee Deduction auto-deducted on-chain), and Payment Phase (Financial Steward final verify → Instant USDC Payout → Fee Auto-Deduction at 1.5% AUM + 8% rental → Investor Dashboard update with on-chain receipt)."&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Stats &amp;amp; System Summary
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Data points to include:&lt;/strong&gt;&lt;br&gt;
    - REITs today use &lt;strong&gt;less than 5%&lt;/strong&gt; of what blockchain can actually do&lt;br&gt;
    - Transactions on Polygon are:&lt;br&gt;
        - &lt;strong&gt;Finalized in under 5 seconds&lt;/strong&gt;&lt;br&gt;
        - Cost &lt;strong&gt;less than $0.001&lt;/strong&gt;&lt;br&gt;
    - Lease approvals happen in &lt;strong&gt;under 12 seconds&lt;/strong&gt;&lt;br&gt;
    - Dividend payouts complete in &lt;strong&gt;15 seconds&lt;/strong&gt;&lt;br&gt;
    - System runs on:&lt;br&gt;
        - &lt;strong&gt;24 nodes&lt;/strong&gt;&lt;br&gt;
        - Across &lt;strong&gt;7 infrastructure layers&lt;/strong&gt;&lt;br&gt;
    - MVP can be built in &lt;strong&gt;12 weeks&lt;/strong&gt;&lt;br&gt;
    - Platform fees are &lt;strong&gt;fully automated on-chain&lt;/strong&gt;:&lt;br&gt;
        - 1.5% of assets (AUM)&lt;br&gt;
        - 8% of rental income&lt;br&gt;
    - Powered by &lt;strong&gt;7 AI agents&lt;/strong&gt;&lt;br&gt;
        - No human approvals in the main execution flow&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before vs After comparison:&lt;/strong&gt;&lt;br&gt;
    1. &lt;strong&gt;Dividends&lt;/strong&gt;&lt;br&gt;
        - Before: Quarterly payouts via wire transfers&lt;br&gt;
        - After: Monthly payouts in USDC delivered in under 15 seconds&lt;br&gt;
    2. &lt;strong&gt;Lease Approval&lt;/strong&gt;&lt;br&gt;
        - Before: Takes weeks with manual review&lt;br&gt;
        - After: Fully automated approval in under 12 seconds end-to-end&lt;br&gt;
    3. &lt;strong&gt;Rent Collection&lt;/strong&gt;&lt;br&gt;
        - Before: Manual tracking and reconciliation&lt;br&gt;
        - After: Automated ACH collection with instant USDC conversion&lt;br&gt;
    4. &lt;strong&gt;Accounting&lt;/strong&gt;&lt;br&gt;
        - Before: Spreadsheet-based and error-prone&lt;br&gt;
        - After: Fully on-chain, immutable settlement&lt;br&gt;
    5. &lt;strong&gt;Property Ownership Records&lt;/strong&gt;&lt;br&gt;
        - Before: Opaque and paper-based title systems&lt;/p&gt;
&lt;h2&gt;
  
  
          - After: Transparent ownership via ERC-721 NFTs on Polygon PoS
&lt;/h2&gt;
&lt;h2&gt;
  
  
  The Business Case
&lt;/h2&gt;
&lt;/blockquote&gt;

&lt;p&gt;The revenue model is straightforward: 1.5% AUM fee plus 8% rental income fee, both deducted automatically on-chain before pro-rata USDC distribution to investors. There is no billing cycle, no invoice, no collections process. The contracts enforce the fee structure atomically at the moment of payout. Acquisition generates an additional 2% fee on property tokenization proceeds, and secondary market transfers carry a 0.3% on-chain fee. The SaaS licensing model — $2,500/month for Starter, $8,000/month for Portfolio — adds recurring infrastructure revenue on top of the transactional fees, and enterprise API access creates a third revenue line for institutional processors who want to build on top of the stack.&lt;/p&gt;

&lt;p&gt;The defensible position is not the token. It is the data. Every property acquisition, tenant screening decision, rent payment, maintenance job, and yield distribution generates structured, queryable, on-chain data that compounds over time. A REIT operating on this infrastructure after three years has a deal-scoring model, a tenant screening model, and a yield prediction model that no new entrant can replicate quickly. The switching cost for an institutional operator running 500 properties through this stack is not just technical — it is the operational history embedded in the system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The investor signal&lt;/strong&gt;: the infrastructure creates a lower cost structure than any traditional REIT operator. No underwriting staff. No leasing agents for routine approvals. No accountants for monthly yield reconciliation. The fixed cost base is the infrastructure, and the infrastructure scales horizontally. A portfolio of 10 properties and a portfolio of 500 properties run on the same stack with KEDA autoscaling handling the load difference automatically.&lt;/p&gt;




&lt;h2&gt;
  
  
  Strategic Considerations &amp;amp; Real Challenges
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Favq6rrnq1n0mgyrjo9fr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Favq6rrnq1n0mgyrjo9fr.png" alt="Modernizing Tokenized Real Estate Investment Trusts (REITs): The 7-Layer Autonomous Stack"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The adoption barrier is not technical. It is institutional. Most REIT operators do not have engineers who can build this stack, and most engineers who can build this stack have not run a real estate portfolio. The gap between the architecture described here and a production deployment is not just code — it is regulatory counsel, smart contract audits (&lt;a href="https://www.certik.com/" rel="noopener noreferrer"&gt;Certik&lt;/a&gt; or Trail of Bits before any mainnet deployment), KYC/AML infrastructure via &lt;a href="https://withpersona.com/" rel="noopener noreferrer"&gt;Persona&lt;/a&gt; and Chainalysis, and the operational change management required to hand routine decisions to an AI agent. Founders who underestimate this timeline end up with a half-finished stack that is worse than the spreadsheet they started with. The realistic closed-loop MVP is 12 weeks for a team that already has the technical depth.&lt;/p&gt;

&lt;p&gt;The regulatory landscape is the second friction point. The &lt;a href="https://eips.ethereum.org/EIPS/eip-1155" rel="noopener noreferrer"&gt;ERC-1155&lt;/a&gt; fractional shares are security tokens. SEC Regulation A+ caps public issuance at $75M per 12-month rolling period. Regulation D 506(c) limits access to accredited investors only. The Compliance Warden runs five REIT qualification tests daily — 75% asset test, 75% gross income test, 90% distribution requirement, 100-shareholder minimum, 5/50 concentration rule — but a DAO vote and a legal opinion are still required before launch. The architecture handles the technical compliance layer; the legal work cannot be automated away.&lt;/p&gt;

&lt;p&gt;The smart contract risk is real. A bug in &lt;code&gt;DividendDistributor.sol&lt;/code&gt; that miscalculates a pro-rata split or allows re-entrancy on a USDC-moving function is not a UI bug — it is a financial loss event. &lt;strong&gt;The mitigation:&lt;/strong&gt; OpenZeppelin battle-tested base contracts, re-entrancy guards on every fund-moving function, a multi-firm audit before mainnet, an emergency pause via DAO multi-sig, and DeFi insurance via a protocol like &lt;a href="https://nexusmutual.io/" rel="noopener noreferrer"&gt;Nexus Mutual&lt;/a&gt;. The risk is manageable. It is not dismissible.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Stack Proves Something the Industry Has Avoided Admitting
&lt;/h2&gt;

&lt;p&gt;The reason traditional REITs still run on spreadsheets is not that blockchain is too complex for real estate. It is that no one has built the operating system layer that makes blockchain the obvious choice at every decision point. This 7-layer stack is that operating system.&lt;/p&gt;

&lt;p&gt;In three to five years, the operators who have built this infrastructure will have a data advantage, an operational cost advantage, and a settlement speed advantage that cannot be replicated by a traditional REIT adding a tokenization feature to its existing stack. The question for founders and institutions in this space is not whether autonomous REITs are possible. The question is whether they build this infrastructure now or buy access to it later.&lt;/p&gt;




&lt;p&gt;If you are a founder or investor building in tokenized real estate, connect with me for a consulting discussion on designing your own autonomous REIT system — &lt;a href="https://dappmentors.org/consult" rel="noopener noreferrer"&gt;book a session at dappmentors.org/consult&lt;/a&gt; (limited to business propositions).&lt;/p&gt;

&lt;p&gt;Watch the full architecture walkthrough on the &lt;a href="https://youtu.be/L7RjU09dvj0" rel="noopener noreferrer"&gt;Beyond Blockchain YouTube channel&lt;/a&gt; — the full Reita architecture video covers every layer and the live journey map animation.&lt;/p&gt;




&lt;h2&gt;
  
  
  About the Author
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/darlington-gospel/" rel="noopener noreferrer"&gt;Darlington Gospel&lt;/a&gt; is an AI + Blockchain + Automation Infrastructure Architect and Strategic Technology Analyst. Founder of Dapp Mentors, Host of &lt;a href="https://www.youtube.com/playlist?list=PLUDcVqFK2t-B1i57WTKABR0S48rnUv3Lw" rel="noopener noreferrer"&gt;&lt;strong&gt;Beyond Blockchain&lt;/strong&gt;&lt;/a&gt;, operating through Dapp Mentors. He designs autonomous AI, blockchain, and automation infrastructure for tokenized real estate systems that run without human intermediaries — writing for global enterprise founders, infrastructure startups, investors, technical leaders, business strategists, and AI/Blockchain/Automation architects.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>blockchain</category>
      <category>automation</category>
    </item>
    <item>
      <title>How I Would Build an Autonomous Pharmaceutical Retail Chain Operating System</title>
      <dc:creator>Darlington Gospel</dc:creator>
      <pubDate>Sat, 14 Mar 2026 20:58:26 +0000</pubDate>
      <link>https://dev.to/daltonic/how-i-would-build-an-autonomous-pharmaceutical-retail-chain-operating-system-5be5</link>
      <guid>https://dev.to/daltonic/how-i-would-build-an-autonomous-pharmaceutical-retail-chain-operating-system-5be5</guid>
      <description>&lt;p&gt;The pharmaceutical retail chain does not have a technology problem. It has a coordination problem that technology has never properly addressed.&lt;/p&gt;

&lt;p&gt;Walk into any mid-size pharmacy chain's back office and you find the same pattern: remittance submitted on a spreadsheet at the end of the day, procurement triggered by a manager's judgment when shelves look thin, supplier payments sitting in a queue waiting for someone to review the invoice. &lt;strong&gt;Branch A&lt;/strong&gt; is out of Amoxicillin. &lt;strong&gt;Branch B&lt;/strong&gt; is about to expire its surplus. Nobody knows. Nobody acts.&lt;/p&gt;

&lt;p&gt;The infrastructure failure here is not just inefficiency — it is the complete absence of a trusted coordination layer between procurement, inventory, inter-branch operations, and financial settlement. The global pharmaceutical retail market exceeds $1.4 trillion annually. Chains are losing billions not because they lack inventory software, but because the software they run does not talk to anything and enforces nothing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Buduka&lt;/strong&gt; is the system I would build to fix this. A seven-layer Autonomous Business Operating System that replaces every manual bottleneck from low-stock detection to supplier payment with AI reasoning, durable automation, and on-chain settlement. Here is the architecture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzw8ddarty8trkvmwr7lq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzw8ddarty8trkvmwr7lq.png" alt="Buduka's complete 7-layer system architecture — 23 nodes spanning Data Ingestion (L01), AI Intelligence (L02), Blockchain &amp;amp; Trust (L03), Automation Fabric (L04), Interface &amp;amp; UX (L05), Infra &amp;amp; Observability (L06), and Payments &amp;amp; Finance (L07) — with cross-layer connections showing how data flows up from POS through agents to Solana contracts and back down through portals and the Payment Gateway."&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Infrastructure Problem
&lt;/h2&gt;

&lt;p&gt;The specific failure point in pharmaceutical retail is not stockouts. Stockouts are a symptom. The root cause is that no system currently coordinates the chain as a single operational unit.&lt;/p&gt;

&lt;p&gt;Every branch runs as an island. POS data stays in the branch system. Procurement decisions get made by individual managers working from memory and gut feel. When a branch finally submits its daily remittance, it goes into a spreadsheet — and if the numbers are disputed two weeks later, there is no immutable record to resolve the disagreement. No &lt;a href="https://en.wikipedia.org/wiki/Audit_trail" rel="noopener noreferrer"&gt;audit trail&lt;/a&gt;. No chain-wide visibility into what was ordered, what was delivered, and what was paid. The data exists in fragments. The trust infrastructure does not exist at all.&lt;/p&gt;

&lt;p&gt;The supplier side is equally broken. Suppliers deliver goods and wait weeks for payment because the settlement workflow depends on a human reviewing an invoice, matching it to a delivery, and approving a bank transfer. That process fails on volume. It fails on speed. It generates disputes that get resolved by email, documented nowhere, and forgotten before the next cycle. Meanwhile, the supplier's performance — on-time rate, GRN accuracy, pricing compliance — is never tracked in any structured way. Poor suppliers stay on the list. Good ones get no advantage.&lt;/p&gt;

&lt;p&gt;The financial reconciliation problem is the one most chains refuse to confront directly. When a pharmacy manager submits remittance, the amount is taken on trust. There is no automated cross-check against POS totals. Discrepancies surface slowly if at all. And because nothing is blockchain-attested, there is no tamper-proof record to anchor a compliance audit. Regulators asking for a three-year procurement history get a spreadsheet archive that nobody can fully trust.&lt;/p&gt;

&lt;p&gt;This is not a problem of lacking the right ERP system. It is a problem of lacking the right infrastructure design — one that treats AI coordination, workflow durability, and on-chain trust as first-class requirements rather than optional add-ons.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Autonomous Pharmaceutical Retail Operating System
&lt;/h2&gt;

&lt;p&gt;Buduka is structured as seven distinct layers. Each layer has a specific function. Each layer connects to the next with defined data contracts. Nothing is coupled by coincidence.&lt;/p&gt;

&lt;p&gt;You can watch the full step-by-step breakdown of the architecture and user journey in the video below, or &lt;a href="https://www.youtube.com/playlist?list=PLUDcVqFK2t-B1i57WTKABR0S48rnUv3Lw" rel="noopener noreferrer"&gt;&lt;strong&gt;explore the full playlist covering different system architectures&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/JsMDYyab62E"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L01 — Data &amp;amp; Ingestion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxzfbcpfxb49fzev7mtg8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxzfbcpfxb49fzev7mtg8.png" alt="Layer 1: Three components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This layer feeds the entire system. Three nodes operate here: the &lt;strong&gt;POS Data Feed&lt;/strong&gt;, the &lt;strong&gt;Inventory DB&lt;/strong&gt;, and &lt;a href="https://en.wikipedia.org/wiki/Apache_Kafka" rel="noopener noreferrer"&gt;&lt;strong&gt;Apache Kafka&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;POS transactions stream in real time. Inventory state is maintained in a structured database with per-branch, per-SKU visibility. Kafka carries every event — stock movements, sales records, reorder signals — through the system with no batch delay and no nightly sync. When stock drops below reorder point at any branch, the event fires instantly. The AI layer receives it within milliseconds.&lt;/p&gt;

&lt;p&gt;The significance of this layer is not the technology. It is the design decision to treat the entire chain as a single event stream rather than a collection of disconnected branch databases. That is the foundational shift that makes everything downstream possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L02 — AI &amp;amp; Intelligence&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvacpvdzrpf37gisawdmp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvacpvdzrpf37gisawdmp.png" alt="Layer 2: Seven components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Seven &lt;code&gt;LangGraph&lt;/code&gt;-based agents operate in this layer. Each has a defined persona, a constrained toolset, and a validated output schema. No agent outputs freeform text into the system — every decision is structured and machine-readable.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Inventory Agent&lt;/strong&gt; monitors every branch continuously. When stock at any branch crosses the reorder threshold, it generates a Branch Order Request with &lt;a href="https://en.wikipedia.org/wiki/Stock_keeping_unit" rel="noopener noreferrer"&gt;SKU&lt;/a&gt; IDs and quantities. The &lt;strong&gt;Demand Aggregator Agent&lt;/strong&gt; collects all branch requests within a six-hour aggregation window and produces a chain-wide demand profile. The &lt;strong&gt;Trade Match Agent&lt;/strong&gt; scans simultaneously for surplus and shortage patterns across branches and proposes net-zero inter-branch transfers. The &lt;strong&gt;Compliance Agent&lt;/strong&gt; verifies every supplier's regulatory attestation before any order is allocated. The &lt;strong&gt;Settlement Agent&lt;/strong&gt; handles GRN verification and constructs payment instructions. The &lt;strong&gt;Performance Agent&lt;/strong&gt; scores suppliers live on delivery rate, accuracy, and compliance. The &lt;strong&gt;Orchestrator Agent&lt;/strong&gt; arbitrates inter-agent conflicts and routes escalations to the correct human actor.&lt;/p&gt;

&lt;p&gt;No manager approves a routine reorder. No supervisor manually matches a supplier invoice. The agents handle this. Human judgment enters the system only at escalation gates — high-value purchase orders that exceed autonomous spend thresholds, trade proposals waiting for manager confirmation, remittance discrepancies that require an explanation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L03 — Blockchain &amp;amp; Trust&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffko99fc1crh6aum6caya.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffko99fc1crh6aum6caya.png" alt="Layer 3: Four components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is where the system earns its credibility. Four Solana smart contracts anchor every consequential operational and financial event.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Solana Settlement Contract&lt;/strong&gt; locks and releases USDC from the central procurement fund wallet — every fund reservation on PO creation and every release on GRN confirmation is on-chain. The &lt;strong&gt;Remittance Attestation Contract&lt;/strong&gt; records the hash of every daily reconciliation result — branch ID, date, POS total, submitted amount, and status — immutably on &lt;a href="https://en.wikipedia.org/wiki/Solana_(blockchain_platform)" rel="noopener noreferrer"&gt;Solana&lt;/a&gt;. The &lt;strong&gt;Procurement Fund Wallet&lt;/strong&gt; is a program-derived address controlled exclusively by the Settlement Contract, holding central procurement capital with a real-time &lt;a href="https://en.wikipedia.org/wiki/Burn_rate" rel="noopener noreferrer"&gt;burn rate&lt;/a&gt; visible to Administration. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Inter-Pharmacy Trade Contract&lt;/strong&gt; anchors every net-zero inter-branch stock transfer with &lt;a href="https://en.wikipedia.org/wiki/Multisignature" rel="noopener noreferrer"&gt;multi-sig&lt;/a&gt; confirmation from both branch managers.&lt;/p&gt;

&lt;p&gt;The business argument for this layer is precise: when a supplier disputes a payment, when a regulator requests a compliance audit, when a branch manager contests a remittance shortfall, the answer is not a spreadsheet. It is a blockchain transaction hash with a timestamp that nobody altered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L04 — Automation Fabric&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyjqjucuavnbj0p00jocy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyjqjucuavnbj0p00jocy.png" alt="Layer 4: : Three components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Temporal&lt;/code&gt;-powered durable workflows operate here. Three primary workflows run on exactly-once execution semantics: &lt;strong&gt;Purchase Order Workflow&lt;/strong&gt;, &lt;strong&gt;Daily Remittance Workflow&lt;/strong&gt;, and &lt;strong&gt;Supplier Settlement Workflow&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The Purchase Order Workflow generates and reserves procurement funds the moment a supplier confirms their allocation. The Daily Remittance Workflow fires at 18:00 UTC for every active branch simultaneously — fetching POS totals, notifying the Pharmacy Manager, waiting for remittance submission, reconciling the result, and anchoring the outcome on-chain. The Supplier Settlement Workflow triggers on &lt;a href="https://en.wikipedia.org/wiki/Goods_receipt" rel="noopener noreferrer"&gt;GRN (Goods Received Note)&lt;/a&gt; confirmation and orchestrates the end-to-end payment process through the Payment Gateway.&lt;/p&gt;

&lt;p&gt;The design requirement for this layer is durability. &lt;a href="https://en.wikipedia.org/wiki/Workflow_engine" rel="noopener noreferrer"&gt;Temporal&lt;/a&gt; workflows survive infrastructure restarts, retry failures automatically, and never lose state. An AI decision that triggers a workflow does not depend on the application server staying healthy. The workflow runs to completion regardless.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L05 — Interface &amp;amp; UX&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5cmlp3twp4rc8fgm31u1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5cmlp3twp4rc8fgm31u1.png" alt="Layer 5: : Four components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Three &lt;code&gt;Next.js&lt;/code&gt; portals serve the three actor classes. The &lt;strong&gt;Supplier Portal&lt;/strong&gt; surfaces aggregated chain-wide demand by SKU — without exposing individual branch data — and handles GRN submission and payment history. The &lt;strong&gt;Pharmacy Manager Portal&lt;/strong&gt; shows branch stock, incoming purchase orders, remittance status, and inter-pharmacy trade options. The &lt;strong&gt;Administration Dashboard&lt;/strong&gt; controls procurement fund status, daily remittance scoreboards, supplier KPI tables, escalation queues, and chain-wide policy parameters.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;Socket.io&lt;/code&gt; &lt;a href="https://en.wikipedia.org/wiki/WebSocket" rel="noopener noreferrer"&gt;&lt;strong&gt;WebSocket&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;Chat Service&lt;/strong&gt; sits alongside the three portals in this layer — correctly classified as an interface component, not a financial one. &lt;/p&gt;

&lt;p&gt;Five room types operate on the hub: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TRADE (manager-to-manager stock negotiations)&lt;/li&gt;
&lt;li&gt;PROCUREMENT (admin-to-supplier PO clarification)&lt;/li&gt;
&lt;li&gt;ESCALATION (admin-to-manager dispute resolution)&lt;/li&gt;
&lt;li&gt;SUPPORT (supplier-to-manager GRN discrepancies)&lt;/li&gt;
&lt;li&gt;BROADCAST (admin to all actors). All conversations are archived for 90 days and auditable by Administration. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Room lifecycle is event-driven — rooms auto-open on operational triggers and auto-close when the linked entity reaches terminal state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L06 — Infra &amp;amp; Observability&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy8j0xstqlnu23be8zgoq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy8j0xstqlnu23be8zgoq.png" alt="Layer 6: One components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;LangSmith&lt;/code&gt; runs the &lt;a href="https://en.wikipedia.org/wiki/Observability_(software)" rel="noopener noreferrer"&gt;observability&lt;/a&gt; layer. Every agent inference, every workflow execution, and every on-chain transaction emits structured telemetry here.&lt;/p&gt;

&lt;p&gt;The system traces complete &lt;a href="https://en.wikipedia.org/wiki/LangChain" rel="noopener noreferrer"&gt;LangGraph&lt;/a&gt; run trees per agent — prompt, structured output, tool call latency, schema validation pass/fail. Alert callbacks trigger the Orchestrator Agent when schema violation rates exceed defined thresholds. The Administration Dashboard receives a live agent health feed pushed by &lt;a href="https://en.wikipedia.org/wiki/LangChain" rel="noopener noreferrer"&gt;LangSmith&lt;/a&gt; webhooks. Without this layer, diagnosing why an allocation decision deviated from expected behavior requires guesswork. With it, the exact reasoning chain is traceable from the triggering event to the final output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L07 — Payments &amp;amp; Finance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwf9e3czev1am9pel7x0p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwf9e3czev1am9pel7x0p.png" alt="Layer 6: Seven components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A dedicated &lt;strong&gt;Payment Gateway&lt;/strong&gt; node sits here alongside the Solana contracts. This is an intentional architectural boundary — payment execution logic is separated from the &lt;a href="https://en.wikipedia.org/wiki/Smart_contract" rel="noopener noreferrer"&gt;smart contract&lt;/a&gt; layer. The Gateway listens for USDC disbursement events from the Settlement Contract, executes on-chain transfers for suppliers with Solana wallets (sub-500ms finality), and initiates Circle bank wires for fiat-payment suppliers. Every payment is signed through a &lt;a href="https://en.wikipedia.org/wiki/Hardware_security_module" rel="noopener noreferrer"&gt;CloudHSM&lt;/a&gt;-backed enterprise wallet. The Gateway broadcasts payment confirmation to the Supplier Portal and the Administration Dashboard simultaneously, and sends a completion signal to the Settlement Workflow to close the GRN lifecycle.&lt;/p&gt;

&lt;h2&gt;
  
  
  Complete System Flow
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Demand Detection&lt;/strong&gt;&lt;br&gt;
Branch POS Event&lt;br&gt;
→ Kafka Ingestion&lt;br&gt;
→ InventoryAgent detects stock movement&lt;br&gt;
→ DemandAggregatorAgent consolidates demand across branches&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Supplier Allocation&lt;/strong&gt;&lt;br&gt;
Demand signal&lt;br&gt;
→ Supplier allocation engine selects supplier&lt;br&gt;
→ Supplier Portal confirmation&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Purchase Order Execution&lt;/strong&gt;&lt;br&gt;
Supplier confirmation&lt;br&gt;
→ PurchaseOrderWorkflow triggered&lt;br&gt;
→ Funds reserved on-chain&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Delivery &amp;amp; Inventory Verification&lt;/strong&gt;&lt;br&gt;
Supplier delivery&lt;br&gt;
→ Goods Received Note (GRN) confirmation&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Financial Settlement&lt;/strong&gt;&lt;br&gt;
GRN confirmation&lt;br&gt;
→ SettlementAgent verification&lt;br&gt;
→ Payment Gateway execution&lt;br&gt;
→ USDC settlement&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Compliance &amp;amp; Audit&lt;/strong&gt;&lt;br&gt;
Settlement completion&lt;br&gt;
→ Remittance attestation recorded&lt;br&gt;
→ LangSmith audit trail logged&lt;/p&gt;

&lt;p&gt;Nothing in that chain waits for a human signature unless a policy threshold demands one.&lt;/p&gt;




&lt;h2&gt;
  
  
  User Experience — How Each Stakeholder Operates
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The Pharmacy Manager&lt;/strong&gt; previously ran on a combination of shelf observation, manual reorder emails, and daily spreadsheet remittance. They had no visibility into whether the supplier had received their order, no knowledge of which neighboring branch was sitting on surplus of what they needed, and no confirmation that the payment they submitted matched what the system recorded. With Buduka, their dashboard shows real-time branch stock, incoming order status, and active trade options. The Inventory Agent handles routine reorders autonomously. When an order requires approval, the Manager gets a time-gated escalation — approve or reject within a defined window, after which inaction routes to Administration. Daily remittance is submitted through the platform, cross-checked against POS totals automatically, and anchored on-chain. The manager's operational cognitive load drops to exception handling.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkhby8xt0hfw5spxkvf0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkhby8xt0hfw5spxkvf0g.png" alt="End-to-end operational flow Part 1 — from Low Stock Detection and Branch Order Request through Demand Aggregation and Supplier Allocation to the Demand Dashboard, Purchase Order Issued, Goods Delivery, and GRN Confirmation — with actors color-coded: Pharmacy Manager (blue), AI Agents (yellow), Blockchain &amp;amp; Trust (green), Supplier (purple), and Administration (orange)."&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;The Supplier&lt;/strong&gt; previously received orders by email or &lt;a href="https://en.wikipedia.org/wiki/Electronic_data_interchange" rel="noopener noreferrer"&gt;EDI&lt;/a&gt;, delivered goods, raised an invoice, and waited. Payment timelines were unpredictable. Disputes about delivery quantities went back and forth with no formal resolution mechanism. With Buduka, the Supplier Portal shows their allocated demand before an order is formally issued — enabling logistics planning. Once goods are delivered and GRN is confirmed, the Payment Gateway executes within milliseconds for USDC-enabled suppliers, or initiates a Circle wire within standard banking windows. Every settlement has a blockchain transaction hash. Every dispute has a SUPPORT chat room with a linked GRN record. Performance scores update in real time, and a supplier's allocation weight in future orders reflects their actual track record.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Administration&lt;/strong&gt; previously operated on reports — end-of-week summaries, month-end reconciliation reviews, quarterly supplier assessments. The data was backward-looking and could not be trusted entirely because it was assembled manually. With Buduka, Administration operates on live infrastructure. Procurement fund balance updates in real time with burn rate and runway projections. Daily remittance scoreboards show every branch's status by 22:00. Supplier KPI tables are scored continuously. Policy parameters — autonomous spend caps, allocation weights, reorder thresholds — are configured through the dashboard and enforced by the agents without manual follow-up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmjbnojwql7z1ydxswdc3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmjbnojwql7z1ydxswdc3.png" alt="End-to-end operational flow Part 2 — from Stock Receipt and Inter-Pharmacy Trade Chat through Net-Zero Trade Execution and Daily Remittance Submission to Remittance Reconciliation, On-Chain Settlement, Payment Gateway execution, Supplier Payment History, and Admin Reconciliation Dashboard."&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Business Case
&lt;/h2&gt;

&lt;p&gt;The revenue model has five legs and a clear moat. &lt;strong&gt;SaaS licensing per pharmacy branch&lt;/strong&gt; provides predictable recurring revenue that scales with the size of the chain — not with transaction volume. &lt;strong&gt;Per-transaction infrastructure fees&lt;/strong&gt; on &lt;a href="https://en.wikipedia.org/wiki/USDC_(cryptocurrency)" rel="noopener noreferrer"&gt;USDC&lt;/a&gt; settlements through the Payment Gateway attach revenue directly to the operational utility the system provides. &lt;strong&gt;Enterprise licensing for chains with 20 or more branches&lt;/strong&gt; captures the segment with the highest willingness to pay, since larger chains carry the largest operational risk from the status quo. &lt;strong&gt;Compliance and operational data products&lt;/strong&gt; sold to regulators and auditors convert the immutable on-chain records into a standalone revenue stream — audit-grade supply chain attestation is a regulated product category in most jurisdictions. &lt;strong&gt;Implementation consulting&lt;/strong&gt; for chains adopting the system covers onboarding complexity and creates a high-value professional services layer.&lt;/p&gt;

&lt;p&gt;The defensibility argument is not speculative. Every month a chain runs on Buduka, it accumulates on-chain attestation records, supplier performance histories, branch remittance patterns, and procurement baselines. That data set becomes the chain's operational intelligence layer. Switching to a competitor means abandoning that history. The network effect applies to the supplier side as well — suppliers onboarded into the Buduka ecosystem are scored, attested, and integrated. Re-onboarding them into a competing system carries real cost and compliance friction.&lt;/p&gt;

&lt;p&gt;For investors evaluating &lt;strong&gt;autonomous business systems&lt;/strong&gt; infrastructure, the signal here is architectural. This is not workflow automation layered on top of an existing ERP. This is a purpose-built operating system that replaces the coordination layer entirely. The switching cost is the point. The data moat is the compounding asset.&lt;/p&gt;




&lt;h2&gt;
  
  
  Strategic Considerations &amp;amp; Real Challenges
&lt;/h2&gt;

&lt;p&gt;The hardest adoption challenge is not technical. It is organizational. Pharmacy chain managers who built their careers on judgment-based procurement and relationship-based supplier management do not readily hand decision authority to an AI agent. The mitigation is not to argue that the AI is better than they are — it is to position Buduka as the system that handles the volume they cannot, while preserving their role for escalations, exceptions, and strategic decisions. Autonomous for routine. Human for consequential. That framing changes the adoption conversation.&lt;/p&gt;

&lt;p&gt;Regulatory complexity across different markets is real. &lt;strong&gt;Blockchain pharmaceutical logistics&lt;/strong&gt; intersects with data residency requirements, controlled substance handling rules, and financial settlement regulations that vary by jurisdiction. The Compliance Agent's on-chain attestation model needs to be configured per regulatory environment, and the controlled substance eligibility gate for inter-pharmacy trades is a hard architectural requirement, not a soft rule. Chains operating across multiple regulatory environments need this baked into the system from day one — not bolted on later.&lt;/p&gt;

&lt;p&gt;Infrastructure cost is the honest friction point for smaller chains. The &lt;code&gt;Temporal&lt;/code&gt; workflow infrastructure, &lt;code&gt;LangSmith&lt;/code&gt; observability, &lt;code&gt;CloudHSM&lt;/code&gt; wallet security, and &lt;code&gt;Solana&lt;/code&gt; settlement layer together represent a meaningful operational baseline cost. The per-branch &lt;a href="https://en.wikipedia.org/wiki/Software_as_a_service" rel="noopener noreferrer"&gt;SaaS&lt;/a&gt; model makes this work financially at scale. For chains under ten branches, the ROI calculation requires a clear analysis of current losses from stockouts, reconciliation disputes, and delayed supplier payments — because that is the number the infrastructure cost is measured against, not some abstract efficiency percentage.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Infrastructure Always Determines the Outcome
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa5tb23pudt7dbxfksvhz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa5tb23pudt7dbxfksvhz.png" alt="Modernizing Pharmaceutical Retail Supply Chain: The 7-Layer Stack"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most pharmaceutical chains will spend the next decade optimizing processes built on fundamentally broken infrastructure. Better spreadsheet templates. Faster email approvals. More responsive supplier portals that still don't talk to the settlement layer. The operational ceiling of that approach is low, and every year spent under it is a year of compounding losses.&lt;/p&gt;

&lt;p&gt;Buduka proves a different thesis: that pharmaceutical retail operations are not inherently complex — they are complex because no one designed the coordination layer correctly. When AI agents reason over live chain-wide data, when automation workflows execute without human bottlenecks, and when every financial transaction is blockchain-attested before it closes, the operational picture changes entirely. Stockouts become detectable and preventable in advance. Supplier payments become instant and irrefutable. Remittance disputes become resolved by on-chain evidence rather than negotiated in email.&lt;/p&gt;

&lt;p&gt;In three to five years, the chains that built this infrastructure will have compounding data advantages that no late adopter can quickly replicate. The ones still running on spreadsheets will be paying for that gap.&lt;/p&gt;




&lt;p&gt;If you want me to design a system like Buduka for your business — an autonomous operating stack that removes manual decisions from your chain operations — the consulting booking link is here: &lt;a href="https://dappmentors.org/consult" rel="noopener noreferrer"&gt;&lt;strong&gt;dappmentors.org/consult&lt;/strong&gt;&lt;/a&gt;. Let's build the infrastructure.&lt;/p&gt;




&lt;h2&gt;
  
  
  About the Author
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/darlington-gospel/" rel="noopener noreferrer"&gt;&lt;strong&gt;Darlington Gospel&lt;/strong&gt;&lt;/a&gt; is an AI, Blockchain &amp;amp; Automation Infrastructure Architect and Strategic Technology Analyst. Host of &lt;a href="https://www.youtube.com/playlist?list=PLUDcVqFK2t-B1i57WTKABR0S48rnUv3Lw" rel="noopener noreferrer"&gt;Beyond Blockchain series&lt;/a&gt;, and Founder of &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Dapp Mentors&lt;/a&gt;. Writing for enterprise founders, infrastructure startups, technical architects, supply chain operators, investors evaluating infrastructure innovation, and global business strategists.&lt;/p&gt;

</description>
      <category>blockchainarchitecture</category>
      <category>supplychainautomation</category>
      <category>infrastructure</category>
      <category>pharmaceuticaltechnology</category>
    </item>
    <item>
      <title>What You Need to Build an Automated AI Crypto Trading Bot</title>
      <dc:creator>Darlington Gospel</dc:creator>
      <pubDate>Tue, 12 Aug 2025 01:57:07 +0000</pubDate>
      <link>https://dev.to/daltonic/what-you-need-to-build-an-automated-ai-crypto-trading-bot-47fa</link>
      <guid>https://dev.to/daltonic/what-you-need-to-build-an-automated-ai-crypto-trading-bot-47fa</guid>
      <description>&lt;h2&gt;
  
  
  Introduction: From a Clueless Beginner to Automated Profits
&lt;/h2&gt;

&lt;p&gt;Six months ago, I knew absolutely nothing about cryptocurrency trading. The crypto markets felt like a chaotic casino where fortunes were made and lost in minutes, and I was completely overwhelmed by the endless charts, technical indicators, and market psychology that seasoned traders seemed to navigate effortlessly.&lt;/p&gt;

&lt;p&gt;But here's what changed everything: I realized I didn't need to become a trading expert overnight. I needed to become a problem-solving programmer who could teach machines to trade better than humans.&lt;/p&gt;

&lt;p&gt;Today, I'm running an autonomous AI crypto trading platform that operates like clockwork—analyzing market sentiment from thousands of news sources, processing real-time price data, making calculated trading decisions, and executing trades automatically. &lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/U7vR_9B2EqA?start=167"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The transformation wasn't magic. It was systematic learning, failed experiments, breakthrough moments, and ultimately combining my programming skills with cutting-edge AI technology. The bot you'll see in the demo has generated consistent profits across multiple cryptocurrencies, with sophisticated risk management that keeps losses minimal while capturing market opportunities.&lt;br&gt;
I'm going to show you the exact path I took—not just the successes, but the failures that taught me why most trading bots fail spectacularly and how AI-powered systems represent a fundamental shift in automated trading.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Reality Check: Why Most Trading Bots Fail
&lt;/h2&gt;

&lt;p&gt;Before diving into solutions, let's address the uncomfortable truth: most trading bots are expensive disappointments.&lt;/p&gt;

&lt;p&gt;Traditional trading bots rely on static algorithms—rigid rules like "buy when the price crosses above the 50-day moving average" or "sell when RSI exceeds 70." These approaches worked reasonably well in traditional markets where patterns were more predictable, but cryptocurrency markets are different beasts entirely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Volatility Problem&lt;/strong&gt;:&lt;br&gt;
Crypto markets can swing 10-20% in minutes based on a single tweet, regulatory news, or whale movement. Static algorithms can't adapt to these sudden shifts in market psychology.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Sentiment Gap&lt;/strong&gt;:&lt;br&gt;
Traditional technical analysis ignores the human element—the fear, greed, and hype that drive crypto prices. While your bot is calculating moving averages, the market might be reacting to breaking news about regulatory changes or celebrity endorsements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Scalability Issue&lt;/strong&gt;:&lt;br&gt;
Even if you create rules that work for Bitcoin, they might fail completely for smaller altcoins with different trading patterns and liquidity profiles.&lt;/p&gt;

&lt;p&gt;This is where AI-powered systems create a paradigm shift. Instead of following rigid rules, they continuously learn from market data, news sentiment, and trading patterns. They adapt their strategies in real-time, weigh multiple factors simultaneously, and most importantly—they understand context in ways that traditional algorithms simply cannot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3ip4pyg2fj75bnd5ary.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3ip4pyg2fj75bnd5ary.png" alt="Automated AI Trading Bot Platform Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Essential Components: Breaking Down the AI Trading Stack
&lt;/h2&gt;

&lt;p&gt;Building an effective AI crypto trading bot requires four interconnected layers, each serving a critical purpose in the decision-making process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. Data Collection Layer&lt;/strong&gt;&lt;br&gt;
Your AI is only as smart as the data it processes. This layer continuously gathers three types of critical information:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Historical Market Data&lt;/strong&gt; serves as the training ground for your AI models. Just like a human trader studies past price movements to identify patterns, your AI needs months or years of historical data to understand how different cryptocurrencies behave under various market conditions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-time Price Feeds&lt;/strong&gt; provide the live market data necessary for execution decisions. This isn't just current prices—it includes trading volume, order book depth, and market momentum indicators that help the AI understand the immediate trading environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;News Sentiment Analysis&lt;/strong&gt; bridges the gap between technical analysis and market psychology. The system continuously monitors cryptocurrency news sources, social media sentiment, and major market announcements, using natural language processing to gauge whether the overall market mood is bullish, bearish, or uncertain.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyaz37kn5o49hk4migwer.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyaz37kn5o49hk4migwer.png" alt="Real-time sentiment analysis showing how AI processes thousands of news articles and social media posts to gauge market psychology"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B. AI Processing Engine&lt;/strong&gt;&lt;br&gt;
This is where the magic happens—where raw data transforms into trading intelligence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Large Language Models (LLMs)&lt;/strong&gt; process news articles and market commentary, extracting meaningful insights about how current events might impact cryptocurrency prices. Unlike humans who might miss subtle connections, LLMs can simultaneously analyze hundreds of news sources and identify sentiment patterns across different cryptocurrencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Machine Learning Models&lt;/strong&gt; handle the predictive analytics, identifying patterns in price movements, volume changes, and technical indicators that suggest profitable trading opportunities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk Management Algorithms&lt;/strong&gt; ensure that potential profits never come at the cost of catastrophic losses. These systems calculate position sizes, set stop-loss levels, and diversify trades to protect capital during market downturns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Portfolio Optimization Logic&lt;/strong&gt; balances the entire portfolio, deciding how much capital to allocate to each trading opportunity based on expected returns, risk levels, and correlation with other holdings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffjn3tku38pruyis7z7be.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffjn3tku38pruyis7z7be.png" alt="Inside the AI brain - how LLMs, ML models, and risk algorithms work together to make trading decisions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C. Trading Execution System&lt;/strong&gt;&lt;br&gt;
Having great insights means nothing without flawless execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exchange API Integration&lt;/strong&gt; connects your bot to cryptocurrency exchanges, enabling seamless buying and selling across multiple platforms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Order Management&lt;/strong&gt; handles the technical details of trade execution—optimizing order types, timing entries and exits, and managing partial fills.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Capital Allocation&lt;/strong&gt; distributes available funds across different trading opportunities according to the risk-return profiles calculated by the AI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Performance Tracking&lt;/strong&gt; monitors every trade, calculating profits and losses, and feeding performance data back into the system for continuous improvement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;D. User Interface &amp;amp; Control&lt;/strong&gt;&lt;br&gt;
Even autonomous systems need human oversight.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Real-time Dashboard&lt;/strong&gt; provides instant visibility into bot performance, current holdings, and market conditions. &lt;strong&gt;Performance Visualization&lt;/strong&gt; tools help you understand how your bot is performing over different time periods and market conditions. &lt;strong&gt;Manual Override Capabilities&lt;/strong&gt; ensure you maintain ultimate control, allowing you to pause trading, adjust parameters, or intervene during unusual market conditions. &lt;strong&gt;Reporting and Analytics&lt;/strong&gt; features provide detailed insights into trading patterns, helping you optimize the system over time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5qz4hlc7eznxmdwg957i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5qz4hlc7eznxmdwg957i.png" alt="Complete trading dashboard showing real-time performance, portfolio management, and control interfaces"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/U7vR_9B2EqA?t=167&amp;amp;si=Eb-cJcOulwfvHkfu" rel="noopener noreferrer"&gt;&lt;strong&gt;Want to see these components working together? Check out the full system demo&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical Deep Dive: The Technologies That Make It Possible
&lt;/h2&gt;

&lt;p&gt;Choosing the right technology stack can make the difference between a hobby project and a production-grade trading system. Here's why each technology was selected and how they work together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backend Technologies&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Python&lt;/strong&gt; forms the backbone of the system because it's the lingua franca of AI and machine learning. With libraries like scikit-learn, pandas, and numpy, Python provides unmatched support for data analysis and model development. More importantly, most AI research and tools are Python-first, ensuring compatibility with cutting-edge developments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FastAPI&lt;/strong&gt; powers the backend API because speed matters in trading systems. FastAPI provides automatic API documentation, built-in data validation, and exceptional performance—crucial when your bot needs to process market data and execute trades in milliseconds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MongoDB&lt;/strong&gt; handles data storage because cryptocurrency trading generates massive amounts of unstructured data. Historical prices, news articles, sentiment scores, and trading logs don't fit neatly into traditional relational database schemas. MongoDB's document-based structure and horizontal scaling capabilities make it ideal for high-frequency trading data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ollama&lt;/strong&gt; manages interactions with large language models, providing a standardized interface for processing news sentiment and generating trading insights. This abstraction layer allows you to experiment with different LLMs without rewriting core logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker&lt;/strong&gt; ensures consistent deployment across different environments. Trading systems often run on cloud servers, local machines, or dedicated hardware, and Docker containers eliminate the "it works on my machine" problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Frontend Technologies&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Next.js + TypeScript&lt;/strong&gt; creates the responsive trading dashboard because real-time data visualization demands performance and type safety. Next.js provides server-side rendering for fast initial loads, while TypeScript catches errors before they reach production.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React Components&lt;/strong&gt; handle real-time data visualization, updating charts and metrics as new market data arrives. The component-based architecture makes it easy to add new visualization features without disrupting existing functionality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tailwind CSS&lt;/strong&gt; provides professional UI design with minimal custom CSS. In trading applications where users need to quickly process large amounts of information, consistent, clean design isn't just aesthetic—it's functional.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI &amp;amp; Data Technologies&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;LLM Integration&lt;/strong&gt; processes news and social media content, converting unstructured text into structured sentiment scores that the trading algorithm can incorporate into decision-making.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scikit-learn&lt;/strong&gt; handles the machine learning predictive modeling, providing battle-tested algorithms for pattern recognition in price data and feature engineering.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Playwright&lt;/strong&gt; enables automated data harvesting from websites that don't provide APIs, ensuring your bot has access to comprehensive market information even from non-traditional sources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-time APIs&lt;/strong&gt; connect to cryptocurrency exchanges and market data providers, ensuring your bot always operates with the most current information available.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff4icte6zqmvm43294m5n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff4icte6zqmvm43294m5n.png" alt="How data flows through the system - from exchange APIs through AI processing to trading execution"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Trading Strategy: Where AI Meets Market Psychology
&lt;/h2&gt;

&lt;p&gt;The secret to successful automated trading isn't just having good technology—it's implementing a strategy that acknowledges both market mechanics and human psychology.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-factor Analysis Approach&lt;/strong&gt;&lt;br&gt;
Rather than relying on a single indicator, the AI system evaluates multiple factors simultaneously. Technical indicators like moving averages and RSI provide insights into price momentum, while volume analysis reveals whether price movements have strong support. Market sentiment from news analysis adds context about why prices are moving, and correlation analysis with other cryptocurrencies helps identify market-wide trends versus asset-specific movements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sentiment Weighting in Decision-Making&lt;/strong&gt;&lt;br&gt;
Here's where AI systems excel beyond human traders: they can simultaneously process sentiment from thousands of sources without emotional bias. The system assigns sentiment scores to news articles, social media trends, and regulatory announcements, then weighs these scores against technical indicators. For example, strong technical buy signals might be downgraded if news sentiment suggests regulatory crackdowns, while weak technical signals might be amplified during periods of positive market sentiment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk-Adjusted Position Sizing&lt;/strong&gt;&lt;br&gt;
The AI doesn't just decide what to buy—it calculates exactly how much to risk on each trade based on historical volatility, current market conditions, and portfolio correlation. High-confidence trades with strong risk-reward ratios get larger position sizes, while experimental trades or highly volatile assets get smaller allocations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Market Condition Adaptation&lt;/strong&gt;&lt;br&gt;
Perhaps most importantly, the system recognizes that market conditions change. Strategies that work in bull markets may fail during bear markets or sideways trading periods. The AI continuously evaluates current market regimes and adjusts its approach accordingly—becoming more conservative during high volatility periods and more aggressive when opportunities present clear risk-reward profiles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backtesting and Validation&lt;/strong&gt;&lt;br&gt;
Before risking real capital on any strategy modification, the system validates changes against historical data. This isn't simple backtesting that assumes perfect execution—the validation process includes realistic transaction costs, slippage, and market impact to ensure strategies remain profitable in real-world conditions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnhreowb8krhnvxmco1f7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnhreowb8krhnvxmco1f7.png" alt="Comprehensive backtesting results showing strategy performance across different market conditions with realistic costs included"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://buymeacoffee.com/dappmentors/e/444775" rel="noopener noreferrer"&gt;&lt;strong&gt;Ready to implement these strategies yourself? My complete course walks you through every line of code&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-World Challenges and Solutions
&lt;/h2&gt;

&lt;p&gt;Building a production trading system means solving problems that theoretical discussions often ignore.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Technical Challenges&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;API Rate Limiting and Data Reliability&lt;/strong&gt;: Cryptocurrency exchanges impose strict rate limits and occasionally experience downtime during high volatility periods. The solution involves implementing intelligent request throttling, failover systems that switch between multiple data providers, and local caching to reduce API dependencies during critical trading periods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Latency Optimization&lt;/strong&gt;: In crypto markets where prices can move significantly in seconds, every millisecond matters. This requires optimizing network connections, using geographically distributed servers close to exchange data centers, and implementing efficient data processing pipelines that minimize computational delays.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error Handling and System Resilience&lt;/strong&gt;: Trading systems must continue operating even when individual components fail. This means implementing comprehensive logging, automatic restart procedures, graceful degradation when non-critical services are unavailable, and fail-safe mechanisms that protect capital during system errors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trading Fee Considerations&lt;/strong&gt;: Transaction costs can quickly erode profits from automated trading. The system must calculate all fees—trading commissions, network fees, spread costs—and incorporate them into profitability calculations before executing any trade.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Market Challenges&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Handling Extreme Volatility&lt;/strong&gt;: Crypto markets can experience 50%+ price swings during black swan events. The system includes volatility circuit breakers that reduce position sizes or halt trading entirely when market conditions exceed historical norms, protecting capital during unpredictable periods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Avoiding Overfitting to Historical Data&lt;/strong&gt;: Machine learning models can become too specialized to past market conditions, failing when markets behave differently. Regular model retraining, out-of-sample validation, and ensemble methods help ensure the system remains robust across different market environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adapting to Changing Market Conditions&lt;/strong&gt;: Market structure evolves as institutional adoption increases, new regulations emerge, and trading patterns shift. The system includes mechanisms to detect when historical relationships break down and requires human intervention to update strategies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Managing Drawdown Periods&lt;/strong&gt;: Even the best trading systems experience losing streaks. Proper capital management, position sizing, and psychological preparation for drawdown periods prevent emotional decision-making during temporary setbacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Regulatory and Risk Considerations&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Exchange Compliance Requirements&lt;/strong&gt;: Different jurisdictions have varying regulations about automated trading, data storage, and financial reporting. The system includes audit trails, compliance reporting features, and jurisdiction-specific configurations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Capital Preservation Strategies&lt;/strong&gt;: The primary goal isn't maximizing profits—it's preserving capital while generating consistent returns. This means conservative position sizing, diversification across multiple assets, and strict stop-loss disciplines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Monitoring and Alerting Systems&lt;/strong&gt;: Automated systems require human oversight. The platform includes real-time monitoring, automated alerts for unusual conditions, and comprehensive reporting to ensure you maintain awareness of system performance and market conditions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frtrey4pgq7otzg9t93lv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frtrey4pgq7otzg9t93lv.png" alt="From personal trading to business empire - how to scale your AI trading bot into a SaaS platform or client solution"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Beyond Personal Trading: The Business Opportunity
&lt;/h2&gt;

&lt;p&gt;The technology stack we've discussed isn't just for personal trading—it represents a significant business opportunity for developers and entrepreneurs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Building Trading Bots for Clients&lt;/strong&gt;&lt;br&gt;
High-net-worth individuals and small hedge funds often lack the technical expertise to build sophisticated trading systems. With the complete codebase and commercial license, you can customize the platform for specific client needs, charge setup fees, ongoing management fees, or performance-based compensation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SaaS Trading Platform Development&lt;/strong&gt;&lt;br&gt;
The modular architecture makes it straightforward to build a multi-tenant SaaS platform where users can configure their own trading strategies, deposit funds, and monitor performance through personalized dashboards. This creates recurring revenue opportunities with minimal ongoing development costs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hedge Fund Technology Solutions&lt;/strong&gt;&lt;br&gt;
Institutional clients require enterprise-grade features like advanced risk management, regulatory reporting, and multi-asset support. The foundational platform can be extended with these features, targeting hedge funds and asset managers who want proven AI trading technology without building from scratch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Educational and Consulting Services&lt;/strong&gt;&lt;br&gt;
As AI trading becomes mainstream, demand for expertise in building and optimizing these systems will grow exponentially. The deep technical knowledge gained from building the platform positions one to offer consulting services, educational workshops, or even develop additional courses targeting different market segments.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://buymeacoffee.com/dappmentors/e/444812" rel="noopener noreferrer"&gt;&lt;strong&gt;The complete source code with commercial-use license is included in the course&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp4kra3upwd8oopym1yvg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp4kra3upwd8oopym1yvg.png" alt="4-phase learning path from architecture understanding to production deployment - your roadmap to success"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started: Your Roadmap to Building
&lt;/h2&gt;

&lt;p&gt;Success in building an AI trading bot depends on systematic progression through four distinct phases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites and Preparation&lt;/strong&gt;&lt;br&gt;
You'll need basic proficiency in JavaScript and Python—not expert level, but comfortable with variables, functions, and basic data structures. The development environment requires Node.js for the frontend, Python 3.8+ for the backend, Docker for containerization, and accounts with cryptocurrency exchanges for testing and live trading.&lt;/p&gt;

&lt;p&gt;Understanding basic trading concepts helps but isn't required. The course covers necessary trading knowledge within the context of building the bot, so programming background is more important than market expertise.&lt;/p&gt;

&lt;p&gt;Hardware requirements are modest—any modern laptop can handle development, though you'll eventually want cloud hosting for production deployment to ensure 24/7 operation and low-latency connections to exchanges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learning Path Recommendations&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Phase 1: Understanding the Architecture&lt;/strong&gt; involves studying the system design, data flow, and component interactions. This foundation prevents confusion later when building individual pieces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 2: Building Core Components&lt;/strong&gt; focuses on implementing the data collection layer, database design, and basic API structures. Getting these fundamentals right ensures the advanced AI features have a solid foundation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 3: AI Integration and Testing&lt;/strong&gt; introduces machine learning models, sentiment analysis, and trading logic. This phase includes extensive backtesting to validate strategies before risking real capital.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 4: Deployment and Optimization&lt;/strong&gt; covers containerization with Docker, cloud deployment, monitoring systems, and performance optimization for production environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources and Tools&lt;/strong&gt;&lt;br&gt;
Development tools include Visual Studio Code with Python and JavaScript extensions, Git for version control, and database management tools for MongoDB. Data sources encompass cryptocurrency exchange APIs, financial news feeds, and market data providers—both free and premium options depending on requirements.&lt;/p&gt;

&lt;p&gt;Testing frameworks include pytest for Python backend testing, Jest for JavaScript frontend testing, and specialized financial backtesting libraries for strategy validation. Monitoring and analytics platforms help track system performance, trading results, and technical metrics in production environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion: The Future of Automated Trading
&lt;/h2&gt;

&lt;p&gt;The convergence of artificial intelligence and cryptocurrency trading represents more than just a technological advancement—it's the foundation of how financial markets will operate in the coming decade.&lt;/p&gt;

&lt;p&gt;AI is transforming trading forever by eliminating human emotional biases, processing information at superhuman scales, and identifying patterns that would be impossible for manual analysis. Early adopters who master these technologies today will have significant competitive advantages as the financial industry increasingly adopts AI-driven approaches.&lt;/p&gt;

&lt;p&gt;These skills are becoming increasingly valuable across the fintech sector. Major banks, hedge funds, and fintech startups are desperately seeking developers who understand both AI technology and financial markets. The combination is rare enough that expertise in this area commands premium compensation and opens doors to fascinating career opportunities.&lt;/p&gt;

&lt;p&gt;The time to start building is now. The cryptocurrency market is still young enough that individual developers can compete with institutional players, and the AI tools necessary to build sophisticated trading systems have never been more accessible.&lt;/p&gt;

&lt;p&gt;But theoretical knowledge isn't enough. The only way to truly understand automated trading is to build, test, and deploy a real system that trades real money in real markets. That's exactly what we'll do together in this comprehensive course.&lt;/p&gt;

&lt;p&gt;The future of trading isn't about humans versus machines—it's about humans who understand machines having massive advantages over those who don't.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh24elgw6dhe7v2hn6tb8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh24elgw6dhe7v2hn6tb8.png" alt="Get started with the complete AI Trading Bot Mastery course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't just read about the future of trading—build it. Get started with the complete&lt;/strong&gt; &lt;a href="https://buymeacoffee.com/dappmentors/extras" rel="noopener noreferrer"&gt;&lt;strong&gt;AI Trading Bot Mastery course&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;a href="https://youtu.be/U7vR_9B2EqA" rel="noopener noreferrer"&gt;&lt;strong&gt;watch the live demo&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Technical Spotlight: How AI Processes Market Sentiment&lt;/strong&gt;&lt;br&gt;
Traditional trading bots ignore the human element of markets, but AI systems excel at understanding the emotional context behind price movements. When the AI encounters news like "SEC announces new crypto regulations," it doesn't just categorize this as "regulatory news"—it understands the historical impact of regulatory announcements on different cryptocurrencies, weighs the severity of the language used, and factors in current market sentiment to predict whether prices will rise or fall.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pro Tip: Start with Paper Trading&lt;/strong&gt;&lt;br&gt;
Before deploying real capital, run your AI trading bot with simulated money for at least 30 days. This allows you to validate your strategies, identify edge cases, and build confidence in the system's decision-making process without financial risk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Pitfall: Over-Optimization&lt;/strong&gt;&lt;br&gt;
The biggest mistake in automated trading is creating systems that work perfectly on historical data but fail in live markets. Always reserve a portion of your historical data for final validation testing, and never optimize strategies based on short-term results—cryptocurrency markets can remain irrational far longer than your account can remain solvent.&lt;/p&gt;

&lt;h2&gt;
  
  
  About Author
&lt;/h2&gt;

&lt;p&gt;I am a web3 developer and the founder of &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Dapp Mentors&lt;/a&gt;, a company that helps businesses and individuals build and launch decentralized applications. I have over 7 years of experience in the software industry, and I am passionate about using blockchain technology to create new and innovative applications. I run a &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube channel called Dapp Mentors&lt;/strong&gt;&lt;/a&gt; where I share tutorials and tips on web3 development, and I regularly post articles online about the latest trends in the blockchain space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stay connected with us, join communities on&lt;/strong&gt;&lt;br&gt;
Discord: &lt;a href="https://discord.gg/PgFDUVT6n9" rel="noopener noreferrer"&gt;Join&lt;/a&gt;&lt;br&gt;
X-Twitter: &lt;a href="https://twitter.com/iDaltonic" rel="noopener noreferrer"&gt;Follow&lt;/a&gt;&lt;br&gt;
LinkedIn: &lt;a href="https://www.linkedin.com/company/dapp-mentors" rel="noopener noreferrer"&gt;Connect&lt;/a&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/Daltonic" rel="noopener noreferrer"&gt;Explore&lt;/a&gt;&lt;br&gt;
Website: &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Visit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>cryptocurrency</category>
      <category>python</category>
      <category>automation</category>
    </item>
    <item>
      <title>Build a Web3 Movie Streaming dApp using NextJs, Tailwind, and Sia Renterd: Part Three</title>
      <dc:creator>Darlington Gospel</dc:creator>
      <pubDate>Fri, 23 Aug 2024 11:04:25 +0000</pubDate>
      <link>https://dev.to/daltonic/build-a-web3-movie-streaming-dapp-using-nextjs-tailwind-and-sia-renterd-part-three-38ei</link>
      <guid>https://dev.to/daltonic/build-a-web3-movie-streaming-dapp-using-nextjs-tailwind-and-sia-renterd-part-three-38ei</guid>
      <description>&lt;p&gt;Let's dive into the final part of this tutorial series, where we'll integrate the backend with the Frontend, connecting the pieces to complete the file upload application. We will begin by ensuring that authentications in the Frontend are up and running.&lt;/p&gt;

&lt;h2&gt;
  
  
  Web3 Modal Authentication
&lt;/h2&gt;

&lt;p&gt;Create a new folder named 'config' in the Frontend directory and add an index file, resulting in the path &lt;code&gt;/frontend/config/index.tsx&lt;/code&gt;.  Now let’s add the following codes to it.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code sets up a Wagmi configuration for our Web3 application, defining metadata, supported chains, and authentication settings, including wallet and social login options, and stores it in the &lt;code&gt;config&lt;/code&gt; export. We also need to create a context API to keep track of the authentication state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Context API&lt;/strong&gt;&lt;br&gt;
Next, create a new folder named 'context' still in the Frontend directory and add an index file, resulting in the path &lt;code&gt;/frontend/context/index.tsx&lt;/code&gt;.  Add the following codes to it.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code sets up a Web3Modal provider using Wagmi and React Query, configuring the Web3 modal with the project ID and theme variables, and wrapping the application in a WagmiProvider and QueryClientProvider.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Updating Layout&lt;/strong&gt;&lt;br&gt;
Let’s have our application layout updated to include the above configurations. Head to &lt;code&gt;/frontend/app/layout.tsx&lt;/code&gt; and replace its codes with the one below.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The above code sets up the root layout for a Next.js application, including metadata, fonts, styles, and providers for Web3 modal, toast notifications, and layout components like header and footer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Login Button&lt;/strong&gt;&lt;br&gt;
Now, we need to enable the login buttons in the &lt;code&gt;/frontend/app/components/layout/Header.tsx&lt;/code&gt; and &lt;code&gt;/frontend/app/components/shared/Menu.tsx&lt;/code&gt; components, and update their codes using the information below.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines a React component for a navigation bar that includes a logo, navigation links, a custom menu, and a login button that launches a Web3 Modal, with a responsive design for different screen sizes.&lt;/p&gt;

&lt;p&gt;The following images should pop up as proof that what we have done works when you click on the login button and proceed with your preferred provider, X, Facebook, Google, Discord, or Ethereum.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj9hpitw55j8l8tlffncu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj9hpitw55j8l8tlffncu.png" alt="Before Authentication" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Focsiuuhznlet3tgqv2bh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Focsiuuhznlet3tgqv2bh.png" alt="After Authentication" width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Superb, let’s go deeper and set up our database and NextJs API-based system. For any confusion on the process, please watch the video section below, just make sure you stop at the &lt;strong&gt;02:57:59&lt;/strong&gt; mark.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZJ8YWdVTWUA?start=9305"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Database Scripts
&lt;/h2&gt;

&lt;p&gt;First, let’s update the NextJs configuration script to properly address our pages, and endpoints, and free our remote images from warnings and scrutiny.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines a Next.js configuration object that sets up API route rewrites and image optimization, allowing remote images from any HTTPS hostname and local images from the localhost domain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database Config Script&lt;/strong&gt;&lt;br&gt;
We will be using SQLite for this application, but you are free to use a more robust solution such as MYSQL or NOSQL providers. For the sake of simplicity, let's work with a SQLite flat file.&lt;/p&gt;

&lt;p&gt;Create &lt;code&gt;/frontend/app/api/database.ts&lt;/code&gt; file path and add the codes below in it.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code sets up an SQLite database connection and defines two API functions, &lt;code&gt;apiGet&lt;/code&gt; and &lt;code&gt;apiPost&lt;/code&gt;, to perform GET and POST requests on the database, with error handling and promise-based asynchronous execution. We will be using these codes whenever we wish to send or retrieve data from the database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database Migration Script&lt;/strong&gt;&lt;br&gt;
We need to create both a database flat file and a table to hold all our contents. Create &lt;code&gt;/frontend/app/api/migrations.ts&lt;/code&gt; file path and add the codes below in it.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines a database migration function that creates a 'movies' table with specified columns if it doesn't exist, using SQLite, and logs the result of the operation. Now run the command below in a terminal pointed at the &lt;code&gt;/frontend&lt;/code&gt; directory.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd frontend
$ npx esrun app/api/migrations.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;It should be noted that this process will also create a database flat file called &lt;code&gt;movies.db&lt;/code&gt; at the root of the frontend directory. We have also added this command to the package.json script, so running &lt;code&gt;$ yarn migrate&lt;/code&gt; on the frontend directory should work the same.&lt;/p&gt;

&lt;p&gt;For visual assistance, watch the video below, just stop it at the &lt;strong&gt;03:10:54&lt;/strong&gt; mark.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZJ8YWdVTWUA?start=10679"&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;h2&gt;
  
  
  Application Endpoints
&lt;/h2&gt;

&lt;p&gt;Now, let’s define some endpoints for creating, reading, updating, and deleting movies, we will be using the NextJs API provision to make these endpoints.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create Movie Endpoint&lt;/strong&gt;&lt;br&gt;
To create a movie, the required information includes the user ID, movie name, image, video URL, release date, genre, rating, language, duration, and background description. Create &lt;code&gt;/frontend/app/api/movies/create/route.ts&lt;/code&gt; file path and add the codes below in it.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;This code defines an endpoint to handle POST requests, validate and process movie data, generate a unique slug, and insert the data into a database using an apiPost function while handling errors and returning JSON responses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update Movie Endpoint&lt;/strong&gt;&lt;br&gt;
To update a movie, the required information includes the user ID, slug, and other information provided when creating a movie. Create &lt;code&gt;/frontend/app/api/movies/update/route.ts&lt;/code&gt; file path and add the codes below in it.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines an endpoint to handle POST requests for updating a movie, validating required properties, and executing an SQL query to update the movie data in the database using the apiPost function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Delete Movie Endpoint&lt;/strong&gt;&lt;br&gt;
To delete a movie, the required information includes the user ID and slug of a movie. Create &lt;code&gt;/frontend/app/api/movies/delete/route.ts&lt;/code&gt; file path and add the codes below in it.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines an endpoint to handle POST requests for deleting a movie, validating required properties (userId and slug), and executing an SQL query to delete the movie from the database using the apiPost function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;All Movies Endpoint&lt;/strong&gt;&lt;br&gt;
The optional data required to get movies are pageSize and userId, which can be passed as query parameters to filter and paginate the results. Create &lt;code&gt;/frontend/app/api/movies/all/route.ts&lt;/code&gt; file path and add the codes below in it.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The above code defines an endpoint to handle GET requests for retrieving movies, allowing optional filtering by userId and pagination by pageSize, and returns the results in JSON format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Single Movie Endpoint&lt;/strong&gt;&lt;br&gt;
To retrieve a single movie, the required data is the slug of a movie. Create &lt;code&gt;/frontend/app/api/movies/[slug]/route.ts&lt;/code&gt; file path and add the codes below in it.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines an endpoint to handle GET requests for retrieving a movie by its slug, validating the slug parameter, and executing an SQL query to retrieve the movie data from the database using the apiGet function.&lt;/p&gt;

&lt;p&gt;That marks all the endpoints we will need for this application. If you need a visual aid to help you understand these endpoints better, please watch the video below, just ensure you stop at the &lt;strong&gt;03:48:22&lt;/strong&gt; timestamp.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZJ8YWdVTWUA?start=10679"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Endpoint Integration
&lt;/h2&gt;

&lt;p&gt;Our task is to review and update pre-coded components and pages, explaining each one's purpose and functionality, and documenting the changes we make to the existing code. We will start by creating a service for interacting with the endpoints we previously created in the &lt;code&gt;api&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;Create &lt;code&gt;/frontend/app/services/api.service.ts&lt;/code&gt; file path and add the codes below in it.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This service provides a set of functions to interact with a movie database, allowing the application to fetch movies, fetch a single movie by slug, create a new movie, update an existing movie, delete a movie, and upload files, using API requests and handling errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Application Pages
&lt;/h2&gt;

&lt;p&gt;Let’s review and update the various pages associated with our application. You wouldn’t need to change many things, just the ones highlighted here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create Movie Page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vlalcivts8nl70zn2kd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vlalcivts8nl70zn2kd.png" alt="Create Movie Page" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This page is a movie publishing form that allows users to upload video and image files, input movie details, and submit the form to publish the movie, with validation and error handling, using React and Wagmi libraries.&lt;/p&gt;

&lt;p&gt;Now, update the file found in &lt;code&gt;/frontend/app/pages/create/page.tsx&lt;/code&gt; with the codes below.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The changes made in this code compared to the original one are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Imported the &lt;code&gt;createMovie&lt;/code&gt; function from &lt;code&gt;api.service&lt;/code&gt; and used it in the &lt;code&gt;handleSubmit&lt;/code&gt; function to create a new movie.&lt;/li&gt;
&lt;li&gt;Added the &lt;code&gt;userId&lt;/code&gt; parameter to the &lt;code&gt;createMovie&lt;/code&gt; function call, passing the user's address from the &lt;code&gt;useAccount&lt;/code&gt; hook.&lt;/li&gt;
&lt;li&gt;Updated the &lt;code&gt;handleSubmit&lt;/code&gt; function to use &lt;code&gt;toast.promise&lt;/code&gt; to handle the promise returned by &lt;code&gt;createMovie&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Added error handling to the &lt;code&gt;createMovie&lt;/code&gt; function call in the &lt;code&gt;handleSubmit&lt;/code&gt; function.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These changes enable the form to submit movie data to the API and create a new movie entry, while also handling errors and displaying a success message.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Edit Movie Page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhd7bfmjvgxanftf03yb5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhd7bfmjvgxanftf03yb5.png" alt="Edit Movie Page Similar to the Create Movie Page" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This movie editing page allows authorized users to update movie details, upload posters and videos, and save changes, with validation and error handling, utilizing React, Wagmi, and Next.js, specifically designed for users to edit their movies.&lt;/p&gt;

&lt;p&gt;Now, update the file found in &lt;code&gt;/frontend/app/pages/movies/edit/[slug]/page.tsx&lt;/code&gt; with the codes below.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The upgrades made to the code that is different from the original are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Imported &lt;code&gt;fetchMovie&lt;/code&gt; and &lt;code&gt;updateMovie&lt;/code&gt; functions from &lt;code&gt;@/app/services/api.service&lt;/code&gt; and used them in the &lt;code&gt;useEffect&lt;/code&gt; hook and &lt;code&gt;handleSubmit&lt;/code&gt; function, respectively.&lt;/li&gt;
&lt;li&gt;Replaced the &lt;code&gt;posters.find()&lt;/code&gt; method with the &lt;code&gt;fetchMovie&lt;/code&gt; function to retrieve movie data.&lt;/li&gt;
&lt;li&gt;Updated the &lt;code&gt;handleSubmit&lt;/code&gt; function to call the &lt;code&gt;updateMovie&lt;/code&gt; function with the updated movie details.&lt;/li&gt;
&lt;li&gt;Added error handling to the &lt;code&gt;updateMovie&lt;/code&gt; function call in the &lt;code&gt;handleSubmit&lt;/code&gt; function.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These changes enable our application to interact with our API endpoints to retrieve and update movie data, whereas the original code relied on our local &lt;code&gt;posters&lt;/code&gt; array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Home Page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmu9g0dt9ftqd2hahcahx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmu9g0dt9ftqd2hahcahx.png" alt="Home Page" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This home page renders the banners component, a list of movies (either from an API source or a loading UI), and subscription options, utilizing React and Next.js, to provide an engaging and informative landing page for users.&lt;/p&gt;

&lt;p&gt;Update the file found in &lt;code&gt;/frontend/app/pages/page.tsx&lt;/code&gt; with the following codes.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The changes we made to the home page are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Imported &lt;code&gt;fetchMovies&lt;/code&gt; function from &lt;code&gt;./services/api.service&lt;/code&gt; and used it in the &lt;code&gt;useEffect&lt;/code&gt; hook to retrieve movie data from our API.&lt;/li&gt;
&lt;li&gt;Replaced the local &lt;code&gt;posters&lt;/code&gt; data with the &lt;code&gt;fetchMovies&lt;/code&gt; function call, which fetches data from our API.&lt;/li&gt;
&lt;li&gt;Added &lt;code&gt;await&lt;/code&gt; keyword to wait for the promise returned by &lt;code&gt;fetchMovies&lt;/code&gt; to resolve before setting the &lt;code&gt;movies&lt;/code&gt; state.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These changes help our application to retrieve movie data from our API instead of relying on local data, making the application more dynamic and data-driven.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Account Page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg7j5qw8j7wci4lsq8p21.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg7j5qw8j7wci4lsq8p21.png" alt="Account Page" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This page displays a list of movies posted by the currently connected user, with a loading skeleton placeholder while the data is being fetched, and a message prompting the user to connect their account if they haven't done so, utilizing Wagmi, and react-loading-skeleton.&lt;/p&gt;

&lt;p&gt;Update the file found in &lt;code&gt;/frontend/app/pages/account/page.tsx&lt;/code&gt; with the following codes.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The changes made to the page are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Imported &lt;code&gt;fetchMovies&lt;/code&gt; function from &lt;code&gt;@/app/services/api.service&lt;/code&gt; and used it in the &lt;code&gt;useEffect&lt;/code&gt; hook to retrieve movie data from our API.&lt;/li&gt;
&lt;li&gt;Replaced the local &lt;code&gt;posters&lt;/code&gt; data with the &lt;code&gt;fetchMovies&lt;/code&gt; function call, which fetches data from our API.&lt;/li&gt;
&lt;li&gt;Passed &lt;code&gt;address&lt;/code&gt; as an argument to the &lt;code&gt;fetchMovies&lt;/code&gt; function to retrieve user-specific movie data.&lt;/li&gt;
&lt;li&gt;Removed the conditional check for &lt;code&gt;address&lt;/code&gt; before rendering the movie list, as the &lt;code&gt;fetchMovies&lt;/code&gt; function now handles this logic.&lt;/li&gt;
&lt;li&gt;Simplified the conditional statement for displaying the loading skeleton, as it now only depends on the &lt;code&gt;loaded&lt;/code&gt; state.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These changes retrieve movie data from our API, specific to the connected user, and display a loading skeleton while the data is being fetched.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Movies Details Page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx3vvys655go89v7ny59b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx3vvys655go89v7ny59b.png" alt="Movies Details" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This page displays a single movie's details, including its name, release year, rating, duration, genre, and background information, along with a video player and related movies, and provides options to edit or delete the movie if the user is the owner, utilizing Next.js, and Wagmi.&lt;/p&gt;

&lt;p&gt;Update the file found in &lt;code&gt;/frontend/app/pages/movies/[slug]/page.tsx&lt;/code&gt; with the following codes.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We made some huge changes here! Here's a summary of what we did:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Imported &lt;code&gt;deleteMovie&lt;/code&gt;, &lt;code&gt;fetchMovie&lt;/code&gt;, and &lt;code&gt;fetchMovies&lt;/code&gt; functions from &lt;code&gt;@/app/services/api.service&lt;/code&gt; and used them to interact with our API endpoints.&lt;/li&gt;
&lt;li&gt;Replaced local data with API calls to retrieve movie data.&lt;/li&gt;
&lt;li&gt;Implemented movie deletion functionality using the &lt;code&gt;deleteMovie&lt;/code&gt; function.&lt;/li&gt;
&lt;li&gt;Used &lt;code&gt;toast.promise&lt;/code&gt; to display a notification while deleting a movie.&lt;/li&gt;
&lt;li&gt;Removed the &lt;code&gt;posters&lt;/code&gt; local data and replaced it with API calls.&lt;/li&gt;
&lt;li&gt;Updated the &lt;code&gt;handleSubmit&lt;/code&gt; function to call the &lt;code&gt;deleteMovie&lt;/code&gt; function and handle the response.&lt;/li&gt;
&lt;li&gt;Updated the &lt;code&gt;useEffect&lt;/code&gt; hook to call the &lt;code&gt;fetchMovie&lt;/code&gt; and &lt;code&gt;fetchMovies&lt;/code&gt; functions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These changes cause our application to interact with our API to retrieve and delete movie data and display notifications to the user during the deletion process.&lt;/p&gt;

&lt;p&gt;This part of the video below will show you hands-on how we integrated these pages with the endpoint, please feel free to watch that part if you run into any problem. Just make sure you stop at the &lt;strong&gt;04:57:41&lt;/strong&gt; timestamp.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZJ8YWdVTWUA?start=14070"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Application Components
&lt;/h2&gt;

&lt;p&gt;Let’s discuss the purpose of each component in our application. We will update any component that needs to be modified. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Banner Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqxmsbi8w9zk8lzdti0a9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqxmsbi8w9zk8lzdti0a9.png" alt="Banner Component" width="800" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This component displays a rotating background image of movie banners, cycling through an array of movie images every 5 seconds, creating a simple and automatic slideshow effect. This component code can be assessed at &lt;code&gt;/frontend/app/components/home/Banner.tsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Posters Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuyb4sxbr9lab94usszo9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuyb4sxbr9lab94usszo9.png" alt="Posters Component" width="800" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This component displays a responsive and interactive carousel of movie posters, using the Swiper library, with features like autoplay, pagination, and navigation, showcasing a list of movies passed as a prop, with a dynamic layout adapting to different screen sizes. This component code can be assessed at &lt;code&gt;/frontend/app/components/home/Posters.tsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Poster UI Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frox09zpi9k4g12vjttx9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frox09zpi9k4g12vjttx9.png" alt="Poster UI Component" width="800" height="291"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This component displays a placeholder skeleton layout for a movie posters section, using the react-loading-skeleton library, showing a dynamic number of skeleton posters based on the "posters" prop, with a responsive design adapting to different screen sizes, indicating a loading state until the actual posters data is fetched and displayed. This component code can be assessed at &lt;code&gt;/frontend/app/components/home/PosterUI.tsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Subscriptions Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwq2883kjleflqq59qo54.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwq2883kjleflqq59qo54.png" alt="Subscriptions Component" width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This component displays a subscription plans section, showcasing various dummy plans with their details, prices, and benefits. It allows users to choose a plan that suits their needs, utilizing a responsive grid layout and interactive hover effects to enhance the user experience. This component code can be assessed at &lt;code&gt;/frontend/app/components/home/Subscription.tsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Header Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9njsqjsdh88769fldm3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9njsqjsdh88769fldm3.png" alt="The Header Component" width="800" height="33"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This component renders a fixed navigation bar at the top of the page, featuring a logo, a navigation menu with links to various sections, a menu toggle button for responsive design, and a login button, providing a consistent and accessible header section across the application. This component code can be assessed at &lt;code&gt;/frontend/app/components/layout/Header.tsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Footer Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7po0fqacb1c2g0mi0k7u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7po0fqacb1c2g0mi0k7u.png" alt="Footer Component" width="800" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This component renders a footer section at the bottom of the page, featuring the application's logo, a brief description, navigation links, contact information, and a credit mentioning the decentralized storage solution powered by Sia Foundation, providing a clear and organized footer section with relevant information and links. This component code can be assessed at &lt;code&gt;/frontend/app/components/layout/Footer.tsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Menu Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx82i9jvc3wseq2hgs97m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx82i9jvc3wseq2hgs97m.png" alt="Menu Component" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This component renders a responsive menu toggle button, which when clicked, opens or closes a dropdown menu containing navigation links, allowing users to access various sections of the application on smaller screens while hiding the menu on larger screens where the navigation links are already visible. This component code can be assessed at &lt;code&gt;/frontend/app/components/shared/Menu.tsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Movie Card Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0t6nwtc7m0n9gnaq2sft.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0t6nwtc7m0n9gnaq2sft.png" alt="Movie Card Component" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This component displays a single movie's poster with a hover effect, showing additional information such as the movie's name, release year, and background summary, while also serving as a link to the movie's details page, utilizing a responsive design and animated transitions to enhance the user experience. This component code can be assessed at &lt;code&gt;/frontend/app/components/shared/MovieCard.tsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Uploaded Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fic7dya7gs04u6z8yz7k6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fic7dya7gs04u6z8yz7k6.png" alt="Uploaded Component" width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This component displays a preview of an uploaded file, either an image or a video, with a progress bar and a removal button, allowing users to review and delete the uploaded file, while also providing a visually appealing and interactive interface with animations and hover effects. This component code can be assessed at &lt;code&gt;/frontend/app/components/shared/Uploaded.tsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Uploader Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqj2p9zs5t9uibgtrfmyd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqj2p9zs5t9uibgtrfmyd.png" alt="Uploader Component" width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This component provides a user interface for uploading files, specifically videos or posters, with features like drag-and-drop, file type validation, size limits, upload progress tracking, and success/error notifications, utilizing a combination of React state management, event handling, and API integration to handle the upload process.&lt;/p&gt;

&lt;p&gt;Update the file found in &lt;code&gt;/frontend/app/components/shared/uploader.tsx&lt;/code&gt; with the following codes.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The changes made to this component are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Upload File Functionality&lt;/strong&gt;: The original code didn't have the actual upload file functionality implemented. It only showed a success toast notification without uploading the file. This updated code includes the &lt;code&gt;uploadFile&lt;/code&gt; function from &lt;code&gt;api.service&lt;/code&gt; which handles the file upload.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Progress Tracking&lt;/strong&gt;: The updated code tracks the upload progress and displays it on the UI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Handling&lt;/strong&gt;: The updated code includes error handling for the file upload process.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File Type Validation&lt;/strong&gt;: The updated code uses a more robust file type validation using a regular expression.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Organization&lt;/strong&gt;: The updated code is better organized, with separate functions for handling different tasks, making it easier to read and maintain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UI Updates&lt;/strong&gt;: The updated code includes some UI updates, such as showing the upload progress and a cancel button during upload.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This updated code is more complete and robust, with actual file upload functionality, progress tracking, error handling, and better code organization.&lt;/p&gt;

&lt;p&gt;The video below explains what each component does in more detail, kindly check it out for your betterment.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZJ8YWdVTWUA?start=17861"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;And that is it guys, we have completed this project, and the last step we need to take is to launch this project on the browser. Run &lt;code&gt;$ yarn build &amp;amp;&amp;amp; yarn start&lt;/code&gt; to see the project live on the browser.&lt;/p&gt;

&lt;p&gt;If you encounter any issues, refer to the following resources for troubleshooting, till next time, all the best!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🏠 &lt;a href="https://sia.tech/" rel="noopener noreferrer"&gt;Sia Website&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🔥 &lt;a href="https://sia.tech/software/renterd" rel="noopener noreferrer"&gt;Sia Renterd&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;👨‍💻 &lt;a href="https://api.sia.tech/renterd" rel="noopener noreferrer"&gt;Sia Renterd API&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🚀 &lt;a href="https://sia.tech/discord" rel="noopener noreferrer"&gt;Sia Discord Channel&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💡 &lt;a href="https://www.youtube.com/playlist?list=PLUDcVqFK2t-CZJZ5ihfrVHtLkDhZlLYO-" rel="noopener noreferrer"&gt;YouTube Video Playlist&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  About Author
&lt;/h2&gt;

&lt;p&gt;I am a web3 developer and the founder of &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Dapp Mentors&lt;/a&gt;, a company that helps businesses and individuals build and launch decentralized applications. I have over 8 years of experience in the software industry, and I am passionate about using blockchain technology to create new and innovative applications. I run a &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube channel called Dapp Mentors&lt;/strong&gt;&lt;/a&gt; where I share tutorials and tips on web3 development, and I regularly post articles online about the latest trends in the blockchain space.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>web3</category>
      <category>programming</category>
    </item>
    <item>
      <title>Build a Web3 Movie Streaming dApp using NextJs, Tailwind, and Sia Renterd: Part Two</title>
      <dc:creator>Darlington Gospel</dc:creator>
      <pubDate>Fri, 23 Aug 2024 10:55:33 +0000</pubDate>
      <link>https://dev.to/daltonic/build-a-web3-movie-streaming-dapp-using-nextjs-tailwind-and-sia-renterd-part-two-4cgm</link>
      <guid>https://dev.to/daltonic/build-a-web3-movie-streaming-dapp-using-nextjs-tailwind-and-sia-renterd-part-two-4cgm</guid>
      <description>&lt;h2&gt;
  
  
  The Backend Service
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Welcome Back!&lt;/strong&gt; Please read through &lt;a href="https://dev.to/daltonic/build-a-web3-movie-streaming-dapp-using-nextjs-tailwind-and-sia-renterd-part-one-5338"&gt;Part 1&lt;/a&gt; if you haven't already. Now, let's dive into Part 2: Building the backend service for our web3 movie streaming platform.&lt;/p&gt;

&lt;p&gt;We've provided a starter code for the backend, which currently displays a "Welcome" message when you start the server and visit &lt;code&gt;http://localhost:9000&lt;/code&gt; in your browser. Let's build on this foundation.&lt;/p&gt;

&lt;p&gt;We currently have these codes in the source directory of the backend, and let me briefly explain them to you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Utility Files&lt;/strong&gt;&lt;br&gt;
This folder which can be fully addressed to &lt;code&gt;backend/src/utils&lt;/code&gt; contains two essential files, an HTTP exception handler function and an interface for handling file upload information.&lt;/p&gt;

&lt;p&gt;This code defines a custom &lt;code&gt;HttpException&lt;/code&gt; class that extends the built-in JavaScript &lt;code&gt;Error&lt;/code&gt; class, allowing for the creation of error instances with specific HTTP status codes and messages.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines an interface &lt;code&gt;FileUpload&lt;/code&gt; that represents an uploaded file, specifying its properties such as name, data, size, encoding, and more, providing a structured way to handle file uploads in this backend application.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;And then at &lt;code&gt;backend/src&lt;/code&gt; root folder, we have this &lt;code&gt;index.ts&lt;/code&gt; file which sets up an Express.js server with CORS and file upload support, defines a single GET route that returns a "Welcome" message, and handles errors by catching and re-throwing them as custom HttpExceptions, then starts the server on the port 9000 as specified in the environment variables.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now that we've covered the key files, let's create two new files in a &lt;code&gt;services&lt;/code&gt; folder, each serving a distinct purpose in our application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Service Files
&lt;/h2&gt;

&lt;p&gt;In the &lt;code&gt;backend/src&lt;/code&gt; folder, make a new folder called &lt;code&gt;services&lt;/code&gt; in this location, this is where we'll create two services:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sia Service&lt;/strong&gt;: Handles file uploads, downloads, streaming, and caching, communicating with the Renterd service.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Background Service&lt;/strong&gt;: Manages cached files, automatically removing them after 7 days at midnight daily.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Sia Service
&lt;/h2&gt;

&lt;p&gt;Let’s create a file named &lt;code&gt;sia.service.ts&lt;/code&gt; at the &lt;code&gt;backend/src/services&lt;/code&gt; folder and follow the steps below to formulate this service.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines a &lt;code&gt;SiaService&lt;/code&gt; class that initializes with environment variables for Sia API settings and an origin URL, providing a foundation for managing interactions with the Sia service. Now, let's supply the rest of the codes for this service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Uploading Files to Sia Renterd&lt;/strong&gt;&lt;br&gt;
To upload files to the Sia Network, we will need to add these three methods into the class, two will be private whereas one will be public.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines a private method &lt;code&gt;generateRandomString&lt;/code&gt; that generates a random string of a specified length, composed of uppercase and lowercase letters and numbers, using a loop to select characters randomly from a predefined string. We will use it to rename each file uniquely before shipping a file to Renterd.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The above code defines a private method &lt;code&gt;uploadToSiaService&lt;/code&gt; that uploads a file to Sia Renterd using Axios, handling upload progress and errors, and returning the Axios response or throwing an error if the upload fails.&lt;/p&gt;

&lt;p&gt;The Renterd endpoints are written in the API documentation which you can check out or watch the video below where I explained how the Sia Renterd API documentation.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/zOmUMz0DBQM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Now let’s include the public method which we will later expose as an endpoint in our application.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines a public method &lt;code&gt;uploadFile&lt;/code&gt; that uploads a file by generating a unique identifier, saving the file to a local cache, and then uploading it to the Sia Renterd, returning the file's URL and a success message or throwing an error if the upload fails. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Downloading Files to Sia Renterd&lt;/strong&gt;&lt;br&gt;
To download files to the Sia Network, we will need to add these two methods into the class, one will be private and the other will be public.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines a private method &lt;code&gt;downloadFromSiaService&lt;/code&gt; that retrieves a file from the Sia service, caches it locally, and returns a readable stream of the file, handling errors and returning a 404 image if the file is not found.&lt;/p&gt;

&lt;p&gt;Let’s have those response_files available in the backend directory, else we will experience an error calling the &lt;code&gt;404.png&lt;/code&gt; file. At the &lt;code&gt;backend&lt;/code&gt; directory create another folder called &lt;code&gt;response_files&lt;/code&gt; and copy the following images into it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gqb15fjz8blmy1mxxvc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gqb15fjz8blmy1mxxvc.png" alt="404.png" width="800" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmn3x3k10rb33hhloksy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmn3x3k10rb33hhloksy.png" alt="401.png" width="800" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Perfect, now let’s complete this file download service, also add the method below in the &lt;code&gt;SiaService&lt;/code&gt; class.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines a public method &lt;code&gt;downloadFile&lt;/code&gt; that calls the private method &lt;code&gt;downloadFromSiaService&lt;/code&gt; to retrieve a file from the Sia Renterd and returns the readable stream of the retrieved file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Service Endpoints
&lt;/h2&gt;

&lt;p&gt;It's time we couple these various methods to their respective endpoints, currently, we have just one, but we will need an additional two for uploading and downloading files. File streaming will also utilize the download endpoint.&lt;/p&gt;

&lt;p&gt;Head to the &lt;code&gt;backend/src/index.ts&lt;/code&gt; file and update its content with these codes.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code sets up an Express.js server with CORS and file upload support, defining three endpoints: a welcome message, file upload to the Sia Network, and file download from the Sia Network, using the SiaService class to handle file operations and HttpException for error handling.&lt;/p&gt;

&lt;p&gt;Watch this section of the video below if you require some visual aid, ensure you stop at the &lt;strong&gt;01:50:44&lt;/strong&gt; timestamp.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZJ8YWdVTWUA?start=3795"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;We need to create a cache management service to ensure our server doesn't fill up with unused files by controlling how long files stay in the cache. Its important to know that the only reason we needed this service is to reduce &lt;a href="https://www.cloudflare.com/learning/performance/glossary/what-is-latency/" rel="noopener noreferrer"&gt;data latency&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Background Service
&lt;/h2&gt;

&lt;p&gt;Head to the &lt;code&gt;backend/src/services&lt;/code&gt; folder and create a file called &lt;code&gt;background.service.ts&lt;/code&gt; and add these sequences of code to it.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines a &lt;code&gt;BackgroundService&lt;/code&gt; class that sets up a cache directory and schedules daily jobs using the &lt;code&gt;node-cron&lt;/code&gt; library, initializing the background jobs and logging a confirmation message. Let’s create a method that will be responsible for deleting files older than 7 days in the cache.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deleting Old File&lt;/strong&gt;&lt;br&gt;
Add this method to the &lt;code&gt;BackgroundService&lt;/code&gt; class.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code defines a method called &lt;code&gt;deleteOldFiles&lt;/code&gt; that removes files from a cache directory that are older than 7 days, by reading the directory, checking each file's creation time, removing files that exceed the target time, logging the start and end of the job, and any errors or successful deletions.&lt;/p&gt;

&lt;p&gt;Now, let’s write a function that will utilize the node-cron package to schedule when to execute the file deletion.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This code sets up a daily cron job to run the &lt;code&gt;deleteOldFiles&lt;/code&gt; method every day at midnight (00:00) to perform automatic file cleanup.&lt;/p&gt;

&lt;p&gt;We also need to update the constructor function to schedule the daily Jobs at the instantiation of the background service class.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Perfect, lastly, let’s add this background operation as part of the server process at initialization. Head to the &lt;code&gt;backend/src/index.ts&lt;/code&gt; file and update the app listener method and also importing the background service file.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;You should rerun the backend service command using &lt;code&gt;$ yarn build &amp;amp;&amp;amp; yarn start&lt;/code&gt; and see a terminal printout like the one in the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjn9abqusygjbcla69lw9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjn9abqusygjbcla69lw9.png" alt="Observe the console log from the Background Service" width="800" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you would rather watch how I coded the entire background service, the video below is for you, just ensure you stop at the &lt;strong&gt;02:16:07&lt;/strong&gt; timestamp.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZJ8YWdVTWUA?start=8167"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next Step&lt;/strong&gt;&lt;br&gt;
Congratulations, you are now ready for the final part of this tutorial which is &lt;a href="https://dev.to/daltonic/build-a-web3-movie-streaming-dapp-using-nextjs-tailwind-and-sia-renterd-part-three-38ei"&gt;Part 3&lt;/a&gt;. If you encounter any issues, refer to the following resources for troubleshooting.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🏠 &lt;a href="https://sia.tech/" rel="noopener noreferrer"&gt;Sia Website&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🔥 &lt;a href="https://sia.tech/software/renterd" rel="noopener noreferrer"&gt;Sia Renterd&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;👨‍💻 &lt;a href="https://api.sia.tech/renterd" rel="noopener noreferrer"&gt;Sia Renterd API&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🚀 &lt;a href="https://sia.tech/discord" rel="noopener noreferrer"&gt;Sia Discord Channel&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💡 &lt;a href="https://www.youtube.com/playlist?list=PLUDcVqFK2t-CZJZ5ihfrVHtLkDhZlLYO-" rel="noopener noreferrer"&gt;YouTube Video Playlist&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  About Author
&lt;/h2&gt;

&lt;p&gt;I am a web3 developer and the founder of &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Dapp Mentors&lt;/a&gt;, a company that helps businesses and individuals build and launch decentralized applications. I have over 8 years of experience in the software industry, and I am passionate about using blockchain technology to create new and innovative applications. I run a &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube channel called Dapp Mentors&lt;/strong&gt;&lt;/a&gt; where I share tutorials and tips on web3 development, and I regularly post articles online about the latest trends in the blockchain space.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>web3</category>
      <category>programming</category>
    </item>
    <item>
      <title>Build a Web3 Movie Streaming dApp using NextJs, Tailwind, and Sia Renterd: Part One</title>
      <dc:creator>Darlington Gospel</dc:creator>
      <pubDate>Fri, 23 Aug 2024 10:47:23 +0000</pubDate>
      <link>https://dev.to/daltonic/build-a-web3-movie-streaming-dapp-using-nextjs-tailwind-and-sia-renterd-part-one-5338</link>
      <guid>https://dev.to/daltonic/build-a-web3-movie-streaming-dapp-using-nextjs-tailwind-and-sia-renterd-part-one-5338</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The web is evolving, and Web3 technologies are revolutionizing traditional industries, including video streaming. Platforms like &lt;a href="https://odysee.com/" rel="noopener noreferrer"&gt;Odysee&lt;/a&gt; are leading the charge, offering decentralized alternatives to YouTube and Rumble. Similarly, unlike legacy providers like Google Drive and Dropbox, &lt;a href="https://sia.tech" rel="noopener noreferrer"&gt;&lt;strong&gt;Sia&lt;/strong&gt;&lt;/a&gt; is transforming data storage, providing a privacy-focused and user-centric approach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Join us on a journey to build a cutting-edge Web3 movie streaming dApp&lt;/strong&gt; using NextJs, TypeScript, Tailwind CSS, and Sia Renterd. This tutorial series will guide you in creating a decentralized application that leverages Sia's blockchain technology to ensure user data ownership and privacy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you'll gain the expertise to:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Build a fully functional movie streaming platform to share with friends or use as a school project&lt;/li&gt;
&lt;li&gt;Launch your own SaaS (Software as a Service) application&lt;/li&gt;
&lt;li&gt;Unlock the potential of Web3 technologies in the video streaming industry&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Watch the demo video below&lt;/strong&gt; to see the project in action and &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;subscribe to our channel&lt;/strong&gt;&lt;/a&gt; for more innovative content like this!&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Hgfdesry8Ss"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow along, ensure you have the following tools installed, and familiarity with the stacks will also enhance your understanding:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NodeJs&lt;/li&gt;
&lt;li&gt;NextJs&lt;/li&gt;
&lt;li&gt;Tailwind CSS&lt;/li&gt;
&lt;li&gt;TypeScript&lt;/li&gt;
&lt;li&gt;Docker &lt;em&gt;(required)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This three-part series will cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Part 1: Project Setup&lt;/strong&gt; - Renterd Zen testnet, Package Installations, and environment variables.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Part 2: Backend Development&lt;/strong&gt; - Building the Backend Service&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Part 3: Frontend Development&lt;/strong&gt; - Integrating the Frontend with the Backend service.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you prefer watching the entire development process, &lt;a href="https://www.youtube.com/watch?v=loLGbL2H7ik&amp;amp;list=PLUDcVqFK2t-CZJZ5ihfrVHtLkDhZlLYO-" rel="noopener noreferrer"&gt;&lt;strong&gt;I recommend watching this playlist&lt;/strong&gt;&lt;/a&gt;, in the playlist, everything that is written here and more are captured in the videos. &lt;/p&gt;

&lt;p&gt;With that said, let’s jump into setting up this project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;

&lt;p&gt;We'll start by cloning a prepared repository which includes the Sia Renterd docker compose script, the backend, and frontend services. Run the following commands:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone https://github.com/Daltonic/sia_vid_tv
$ cd sia_vid_tv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now, it's crucial that we switch to our starter branch on this newly cloned GitHub project, and run the below command to have that done.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git checkout 01_starter_branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next, let’s set up the associated environment variable for this Renterd service. Create a &lt;code&gt;.env&lt;/code&gt; file at the root of this project and apply the keys below:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RENTERD_SEED=&amp;lt;RENTERD_SEED_PHRASE&amp;gt;
RENTERD_API_PASSWORD=&amp;lt;YOUR_PREFERED_PASSWORD&amp;gt;
RENTERD_LOG_LEVEL=debug
RENTERD_LOG_DATABASE_LEVEL=error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To get these API keys you will need to have Sia Renterd installed on your machine, please watch this short video below, it pretty much summarizes it all.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/78XCHGWZwhA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Generate a seed phrase with the Renterd application as seen in the above video and include it inside your environment variable as instructed in the above video. Replace the password with something you can easily remember.&lt;/p&gt;

&lt;p&gt;Next, we need to install Docker by &lt;a href="https://www.docker.com/products/docker-desktop/" rel="noopener noreferrer"&gt;downloading it from the official website&lt;/a&gt; if you haven't already. Alternatively, use a free online platform like &lt;a href="https://gitpod.io/" rel="noopener noreferrer"&gt;Gitpod&lt;/a&gt; or a VPS to run a Docker instance, if possible. Otherwise, install it on your local computer.&lt;/p&gt;

&lt;p&gt;Finally, we can spin up a docker container by running the following docker command at the root of this project, ensure that the terminal is at the same directory location as this &lt;code&gt;docker-compose.yml&lt;/code&gt; file.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker compose -f "docker-compose.yml" up -d --build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Note the command to pull down the container: &lt;code&gt;$ docker compose -f "docker-compose.yml" down&lt;/code&gt;. Run this when you want to shut down your Docker instance (but not now).&lt;/p&gt;

&lt;p&gt;If you performed the above instructions correctly, you should see the interface below when you visit your browser at &lt;code&gt;http://localhost:9880&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg6qr18jhrsfxyrm70ycc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg6qr18jhrsfxyrm70ycc.png" alt="Sia Renterd Login interface" width="800" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter your password (from your environment variable) to log in. Then, follow the configuration procedure in the video below to set up your Sia Renterd instance for file uploads, downloads, and streaming.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZJ8YWdVTWUA?start=401"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The above video starts at the &lt;code&gt;6:41&lt;/code&gt; minute mark, please stop at the &lt;code&gt;20:01&lt;/code&gt; mark, this part will visually guide you through the Renterd configuration process. &lt;/p&gt;

&lt;p&gt;Take note that the blockchain synchronization process along with host matching takes up to &lt;code&gt;25 min&lt;/code&gt; to be ready, so you will have to be patient with the whole process.  &lt;/p&gt;

&lt;p&gt;Please create a new bucket on Renterd called &lt;code&gt;vidtv&lt;/code&gt;, where all our files for this project will be stored. if you have executed the above instructions successfully, your Renterd node should be ready for upload and download, see the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4urn6s225i2otzb9h1ju.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4urn6s225i2otzb9h1ju.png" alt="Renterd on Zen testnet" width="800" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Amazing, at this point, our Renterd service is now ready to start receiving files, but we need to communicate with it programmatically.&lt;/p&gt;

&lt;p&gt;Let's round this part one of this tutorial by having the packages and environment variables set up as well for the Backend and Frontend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backend Project Setup&lt;/strong&gt;&lt;br&gt;
Perform the following instructions to have the backend service packages installed and ready for further development.&lt;/p&gt;

&lt;p&gt;Navigate to the backend directory from a new terminal instance using the following commands:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd backend
$ yarn install #you can also use npm install
$ touch .env #or mannually create it at the root of the backend directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next, supply the following information into the environment variables.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SIA_API_BUCKET=vidtv
SIA_API_PASSWORD=&amp;lt;YOUR_PREFERED_PASSWORD&amp;gt;
SIA_API_BASE_URL=http://localhost:9880
ORIGIN=http://localhost:9000
PORT=9000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And now, run &lt;code&gt;$ yarn build &amp;amp;&amp;amp; yarn start&lt;/code&gt; to spin up the backend and to also confirm that it's free from any bug.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Frontend Project Setup&lt;/strong&gt;&lt;br&gt;
Lastly, run the following commands to install the packages associated with the frontend, afterwards, we will run it.&lt;/p&gt;

&lt;p&gt;Navigate to the backend directory from a new terminal instance using the following commands:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd frontend
$ yarn install #you can also use npm install
$ touch .env #or mannually create it at the root of the backend directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next, supply the following information into the environment variables.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NEXT_PUBLIC_PROJECT_ID=&amp;lt;YOUR_WALLET_CONNECT_ID&amp;gt;
NEXT_PUBLIC_FILE_SERVICE_URL=http://localhost:9000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Sign up and create a project with &lt;a href="https://cloud.walletconnect.com/" rel="noopener noreferrer"&gt;Walletconnect&lt;/a&gt; to get your project ID. After you have supplied the project ID to the environment variable, run  &lt;code&gt;$ yarn build &amp;amp;&amp;amp; yarn start&lt;/code&gt; to spin up the backend and to also confirm that it's free from any bug.&lt;/p&gt;

&lt;p&gt;At this point, you will see the interface below when you visit the browser at &lt;code&gt;http://localhost:3000&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmkowk60tlj1wo0iy9rc7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmkowk60tlj1wo0iy9rc7.png" alt="VidTv Homepage" width="800" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvab1fj1tlmquinfqeuty.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvab1fj1tlmquinfqeuty.png" alt="Movie Poster" width="800" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next Step&lt;/strong&gt;&lt;br&gt;
Congratulations on reaching this milestone! Proceed to &lt;a href="https://dev.to/daltonic/build-a-web3-movie-streaming-dapp-using-nextjs-tailwind-and-sia-renterd-part-two-4cgm"&gt;Part 2&lt;/a&gt; to complete the backend service development. If you encounter any issues, refer to the following resources for troubleshooting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🏠 &lt;a href="https://sia.tech/" rel="noopener noreferrer"&gt;Sia Website&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🔥 &lt;a href="https://sia.tech/software/renterd" rel="noopener noreferrer"&gt;Sia Renterd&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;👨‍💻 &lt;a href="https://api.sia.tech/renterd" rel="noopener noreferrer"&gt;Sia Renterd API&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🚀 &lt;a href="https://sia.tech/discord" rel="noopener noreferrer"&gt;Sia Discord Channel&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💡 &lt;a href="https://www.youtube.com/playlist?list=PLUDcVqFK2t-CZJZ5ihfrVHtLkDhZlLYO-" rel="noopener noreferrer"&gt;YouTube Video Playlist&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  About Author
&lt;/h2&gt;

&lt;p&gt;I am a web3 developer and the founder of &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Dapp Mentors&lt;/a&gt;, a company that helps businesses and individuals build and launch decentralized applications. I have over 8 years of experience in the software industry, and I am passionate about using blockchain technology to create new and innovative applications. I run a &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube channel called Dapp Mentors&lt;/strong&gt;&lt;/a&gt; where I share tutorials and tips on web3 development, and I regularly post articles online about the latest trends in the blockchain space.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>web3</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Learn Blockchain Development: A Step-by-Step Guide</title>
      <dc:creator>Darlington Gospel</dc:creator>
      <pubDate>Wed, 10 Jul 2024 18:11:05 +0000</pubDate>
      <link>https://dev.to/daltonic/how-to-learn-blockchain-development-a-step-by-step-guide-30ek</link>
      <guid>https://dev.to/daltonic/how-to-learn-blockchain-development-a-step-by-step-guide-30ek</guid>
      <description>&lt;p&gt;Hello there, and welcome to Dapp Mentors! I'm &lt;a href="https://www.linkedin.com/in/darlington-gospel-aa626b125/" rel="noopener noreferrer"&gt;Darlington Gospel&lt;/a&gt;, and today, I want to share some insights on how to effectively learn blockchain development. Over the years, I've worked on numerous blockchain and smart contract projects, including &lt;a href="https://www.youtube.com/playlist?list=PLUDcVqFK2t-BvxuYVyOY0ifo1sMlS99w-" rel="noopener noreferrer"&gt;&lt;strong&gt;a recent series on Solana&lt;/strong&gt;&lt;/a&gt;. Now, let's dive into the essential steps for mastering blockchain development.&lt;/p&gt;

&lt;p&gt;You can watch this entire breakdown on this YouTube video below, or else you can keep reading on.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/8pbVzcrnrxM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Blockchain development is not for the faint-hearted. It requires time, dedication, and a strategic approach. In this guide, I'll outline six critical steps to help you shorten your learning curve and achieve success in this field.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fscontent-los2-1.xx.fbcdn.net%2Fo1%2Fv%2Ft0%2Ff1%2Fm253%2Fupload_img_py_pred_07_10_2024_06_39_28_2306791625102438341.jpeg%3F_nc_ht%3Dscontent-los2-1.xx.fbcdn.net%26_nc_cat%3D100%26ccb%3D9-4%26oh%3D00_AYBT8CpXgI_OUvU1QNO9JLL121j4XaFPyf2Wv-wNNeWbLQ%26oe%3D66906EB7%26_nc_sid%3D5b3566" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fscontent-los2-1.xx.fbcdn.net%2Fo1%2Fv%2Ft0%2Ff1%2Fm253%2Fupload_img_py_pred_07_10_2024_06_39_28_2306791625102438341.jpeg%3F_nc_ht%3Dscontent-los2-1.xx.fbcdn.net%26_nc_cat%3D100%26ccb%3D9-4%26oh%3D00_AYBT8CpXgI_OUvU1QNO9JLL121j4XaFPyf2Wv-wNNeWbLQ%26oe%3D66906EB7%26_nc_sid%3D5b3566" alt="fig 1: Media generated by meta.ai" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Be Project-Oriented&lt;/strong&gt;&lt;br&gt;
From the outset, have a clear vision of what you want to build. Whether it's an NFT minting project, a decentralized application, or another blockchain project, your learning should be tied to achieving that specific goal. This focused approach will save you time and effort, preventing you from getting lost in irrelevant details.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Points&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Define Your Goal:&lt;/strong&gt; Determine what you want to build. It could be an NFT marketplace, a decentralized voting dApp, or any other blockchain-based solution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stay Focused:&lt;/strong&gt; Concentrate on learning the skills and tools necessary to complete your specific project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid Distractions:&lt;/strong&gt; Don't get sidetracked by unrelated blockchain technologies or programming languages that are not relevant to your project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
If your goal is to create a crowdfunding platform on the blockchain, focus on learning Solidity for crowd-funding smart contract development, don’t go and learn Solidity programming language A to Z, if you do so, it will ensure you spend too much time in the wilderness.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fscontent-los2-1.xx.fbcdn.net%2Fo1%2Fv%2Ft0%2Ff1%2Fm253%2Fupload_img_py_pred_07_10_2024_06_46_53_1784286998806161701.jpeg%3F_nc_ht%3Dscontent-los2-1.xx.fbcdn.net%26_nc_cat%3D100%26ccb%3D9-4%26oh%3D00_AYBGLXjUSECa24jw052n576w1GipbZ97ZOAOHY1E0JbriA%26oe%3D66907D9A%26_nc_sid%3D5b3566" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fscontent-los2-1.xx.fbcdn.net%2Fo1%2Fv%2Ft0%2Ff1%2Fm253%2Fupload_img_py_pred_07_10_2024_06_46_53_1784286998806161701.jpeg%3F_nc_ht%3Dscontent-los2-1.xx.fbcdn.net%26_nc_cat%3D100%26ccb%3D9-4%26oh%3D00_AYBGLXjUSECa24jw052n576w1GipbZ97ZOAOHY1E0JbriA%26oe%3D66907D9A%26_nc_sid%3D5b3566" alt="fig 2: Media generated by meta.ai" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Break Your Project into Smaller Components&lt;/strong&gt;&lt;br&gt;
Breaking your project into smaller, manageable components reduces complexity and makes the learning process less overwhelming. Just like in React development, where you have distinct components like headers and cards, in blockchain development, you need to break down your project into clear, actionable parts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Points&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Identify Components:&lt;/strong&gt; Determine the major parts of your project, such as the front-end interface, back-end logic, smart contracts, and integrations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Divide and Conquer:&lt;/strong&gt; Work on each component individually before integrating them into the final project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simplify:&lt;/strong&gt; Simplifying complex tasks into smaller chunks makes the learning process more manageable and less daunting.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
For the crowdfunding platform, break down the project into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smart contract development for handling fund collection and distribution.&lt;/li&gt;
&lt;li&gt;Front-end development for user interaction.&lt;/li&gt;
&lt;li&gt;Back-end services for data management and user authentication.&lt;/li&gt;
&lt;li&gt;Integration of front-end with smart contracts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fscontent-los2-1.xx.fbcdn.net%2Fo1%2Fv%2Ft0%2Ff1%2Fm253%2Fupload_img_py_pred_07_10_2024_06_39_28_3057487041941638290.jpeg%3F_nc_ht%3Dscontent-los2-1.xx.fbcdn.net%26_nc_cat%3D111%26ccb%3D9-4%26oh%3D00_AYBeJFQPtnobtO4ZxqTzER76Ma0R0kJtH30_qm-zQh1DsA%26oe%3D66907AC1%26_nc_sid%3D5b3566" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fscontent-los2-1.xx.fbcdn.net%2Fo1%2Fv%2Ft0%2Ff1%2Fm253%2Fupload_img_py_pred_07_10_2024_06_39_28_3057487041941638290.jpeg%3F_nc_ht%3Dscontent-los2-1.xx.fbcdn.net%26_nc_cat%3D111%26ccb%3D9-4%26oh%3D00_AYBeJFQPtnobtO4ZxqTzER76Ma0R0kJtH30_qm-zQh1DsA%26oe%3D66907AC1%26_nc_sid%3D5b3566" alt="fig 3: Media generated by meta.ai" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Gather Information Strategically&lt;/strong&gt;&lt;br&gt;
Gathering information is crucial. Focus on learning what's necessary to achieve each component of your project. Avoid getting stuck in &lt;a href="https://www.reddit.com/r/learnprogramming/comments/qrlx5m/what_exactly_is_tutorial_hell/" rel="noopener noreferrer"&gt;"tutorial hell,"&lt;/a&gt; where you endlessly watch videos or read articles without applying the knowledge. Research specific solutions and apply them directly to your project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Points&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Focus on Relevance:&lt;/strong&gt; Search for information specific to the components of your project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Multiple Sources:&lt;/strong&gt; Combine videos, articles, and tutorials to get a well-rounded understanding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stay Updated:&lt;/strong&gt; Blockchain technology evolves rapidly, so ensure you’re learning from up-to-date sources.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
When learning Solidity, look for resources specifically on writing smart contracts for your current project, such as our crowdfunding project. Platforms like Udemy, Coursera, and developer communities like GitHub and Stack Overflow can be invaluable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fscontent-los2-1.xx.fbcdn.net%2Fo1%2Fv%2Ft0%2Ff1%2Fm253%2Fupload_img_py_pred_07_10_2024_06_44_26_7589151583898240354.jpeg%3F_nc_ht%3Dscontent-los2-1.xx.fbcdn.net%26_nc_cat%3D103%26ccb%3D9-4%26oh%3D00_AYD6PYhoV8UIZx3l-W2R9q-1MGlXSsUBiU-11Q9YHu8rjg%26oe%3D6690783D%26_nc_sid%3D5b3566" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fscontent-los2-1.xx.fbcdn.net%2Fo1%2Fv%2Ft0%2Ff1%2Fm253%2Fupload_img_py_pred_07_10_2024_06_44_26_7589151583898240354.jpeg%3F_nc_ht%3Dscontent-los2-1.xx.fbcdn.net%26_nc_cat%3D103%26ccb%3D9-4%26oh%3D00_AYD6PYhoV8UIZx3l-W2R9q-1MGlXSsUBiU-11Q9YHu8rjg%26oe%3D6690783D%26_nc_sid%3D5b3566" alt="fig 4: Media generated by meta.ai" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Be Research-Driven&lt;/strong&gt;&lt;br&gt;
You'll encounter problems as you progress, and solving them requires extensive research. Be thorough and resourceful in your investigations. Relying solely on others for help can hinder your growth. Embrace the challenge and become adept at finding solutions independently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Points&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Investigate Issues:&lt;/strong&gt; When faced with a problem, dive deep into research to find a solution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explore Widely:&lt;/strong&gt; Look at different sources and perspectives to get a comprehensive understanding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learn Independently:&lt;/strong&gt; Develop the ability to solve problems without always relying on others.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
If you encounter an issue with a smart contract function, research similar problems on forums, and ask an A. I assistant, read documentation, and experiment with different solutions in a test environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fscontent-los2-1.xx.fbcdn.net%2Fo1%2Fv%2Ft0%2Ff1%2Fm253%2Fupload_img_py_pred_07_10_2024_06_45_54_2157080166346015977.jpeg%3F_nc_ht%3Dscontent-los2-1.xx.fbcdn.net%26_nc_cat%3D101%26ccb%3D9-4%26oh%3D00_AYDpfcdF7sJNJ2alo6YfsW1_2h79X-7drDEo0zjjWyM_NQ%26oe%3D66906496%26_nc_sid%3D5b3566" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fscontent-los2-1.xx.fbcdn.net%2Fo1%2Fv%2Ft0%2Ff1%2Fm253%2Fupload_img_py_pred_07_10_2024_06_45_54_2157080166346015977.jpeg%3F_nc_ht%3Dscontent-los2-1.xx.fbcdn.net%26_nc_cat%3D101%26ccb%3D9-4%26oh%3D00_AYDpfcdF7sJNJ2alo6YfsW1_2h79X-7drDEo0zjjWyM_NQ%26oe%3D66906496%26_nc_sid%3D5b3566" alt="fig 5: Media generated by meta.ai" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Repeat the Process for All Components&lt;/strong&gt;&lt;br&gt;
Once you solve one component, move on to the next, repeating the process of gathering information, researching, and applying your knowledge. This iterative approach ensures that you comprehensively understand each part of your project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Points&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Iterate:&lt;/strong&gt; Work through each component using the same methodical approach.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Refine:&lt;/strong&gt; Continuously improve and refine each part as you progress.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrate:&lt;/strong&gt; Once all components are developed, integrate them and test the full system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
After developing and testing the smart contract for the crowdfunding platform, move on to the front-end, then the back-end, ensuring each component works perfectly before integrating them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fscontent-los2-1.xx.fbcdn.net%2Fo1%2Fv%2Ft0%2Ff1%2Fm253%2Fupload_img_py_pred_07_10_2024_06_42_41_1166437463563750428.jpeg%3F_nc_ht%3Dscontent-los2-1.xx.fbcdn.net%26_nc_cat%3D111%26ccb%3D9-4%26oh%3D00_AYD4oZpjd7bVwsuX7Ys10vCbzYNicOJNl8Jf-Ac5yMuRjQ%26oe%3D669063F9%26_nc_sid%3D5b3566" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fscontent-los2-1.xx.fbcdn.net%2Fo1%2Fv%2Ft0%2Ff1%2Fm253%2Fupload_img_py_pred_07_10_2024_06_42_41_1166437463563750428.jpeg%3F_nc_ht%3Dscontent-los2-1.xx.fbcdn.net%26_nc_cat%3D111%26ccb%3D9-4%26oh%3D00_AYD4oZpjd7bVwsuX7Ys10vCbzYNicOJNl8Jf-Ac5yMuRjQ%26oe%3D669063F9%26_nc_sid%3D5b3566" alt="fig 6: Media generated by meta.ai" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Teach the Project&lt;/strong&gt;&lt;br&gt;
Teaching what you've learned solidifies your knowledge and enhances your mastery. Create tutorials, write articles, or produce videos explaining your project. Teaching reinforces your understanding and builds your visibility and credibility in the field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Points&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reinforce Knowledge:&lt;/strong&gt; Teaching helps solidify what you’ve learned.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gain Visibility:&lt;/strong&gt; Sharing your knowledge increases your visibility in the blockchain space.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Credibility:&lt;/strong&gt; Demonstrating your expertise through teaching can quickly lead to new opportunities such as landing a new job.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
Create a technical YouTube video or write a technical blog tutorial demonstrating how to build a project, such as our example crowdfunding platform. Explain the challenges you faced and how you overcame them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/uaYjhKs9aXQ" rel="noopener noreferrer"&gt;&lt;strong&gt;Check out our new Solana-based course on YouTube to learn how to Build a Token Sales Dapp with Solana, NextJs, Typescript, Tailwind CSS, Redux, and Phantom.&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/uaYjhKs9aXQ"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;Learning blockchain development requires a strategic, project-oriented approach. By breaking your project into manageable components, gathering targeted information, and embracing research, you can master the necessary skills efficiently. Teaching your knowledge further reinforces your expertise and opens up new opportunities.&lt;br&gt;
Stay tuned for more tutorials and insights on blockchain development. Until next time, keep learning and building!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;About the Author&lt;/strong&gt;&lt;br&gt;
Darlington Gospel is a seasoned blockchain developer and educator with over 8 years of experience. He specializes in blockchain development, fullstack software development, technical instruction, and content creation.&lt;br&gt;
We run a &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube channel called Dapp Mentors&lt;/strong&gt;&lt;/a&gt; where we share tutorials and tips on web3 development, and we regularly post articles online about the latest trends in the blockchain space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;About Dapp Mentors&lt;/strong&gt;&lt;br&gt;
Dapp Mentors is a community dedicated to helping developers transition into web3 development. Our team includes experienced blockchain developers and educators passionate about sharing their knowledge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For more information, contact us at:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/darlington-gospel-aa626b125/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://discord.gg/PgFDUVT6n9" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/iDaltonic" rel="noopener noreferrer"&gt;X-twitter&lt;/a&gt;&lt;br&gt;
&lt;a href="https://youtube.com/@dappmentors" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Website&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>blockchain</category>
      <category>web3</category>
      <category>programming</category>
    </item>
    <item>
      <title>Data-Driven Dapps Storage: Filecoin, Sia, &amp; Arweave Compared</title>
      <dc:creator>Darlington Gospel</dc:creator>
      <pubDate>Fri, 14 Jun 2024 12:12:46 +0000</pubDate>
      <link>https://dev.to/daltonic/data-driven-dapps-storage-filecoin-sia-arweave-compared-g78</link>
      <guid>https://dev.to/daltonic/data-driven-dapps-storage-filecoin-sia-arweave-compared-g78</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Welcome to &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;Dapp Mentors!&lt;/strong&gt;&lt;/a&gt; In this article, we'll explore decentralized blockchain storage networks, a crucial aspect of building decentralized applications (dApps). Unlike regular blockchain networks, which focus on financial transactions, decentralized storage networks store data files across a network of node providers, ensuring no single point of failure.&lt;/p&gt;

&lt;p&gt;You can watch this entire breakdown on this YouTube video, or else you can keep reading on.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/4iJKbjIHqGk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  The Need for Decentralized Storage
&lt;/h2&gt;

&lt;p&gt;Regular blockchain networks like Ethereum and Layer Two are expensive for storing large files, making decentralized storage networks a cost-effective solution. Decentralized storage networks like Filecoin, Sia, and Arweave offer cheap data storage, encryption, and permanency, making them ideal for dApp development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Filecoin
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fejddqqp8win2of9esxps.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fejddqqp8win2of9esxps.png" alt="Filecoin Ecosystem" width="800" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Filecoin uses IPFS as a protocol for storing and sharing files and has been a pioneer in decentralized storage. I appreciate its storage capacity, which allows developers to store files on the network. The concept of miners, storage providers, and clients ensures that data is stored decentralized, making Filecoin a reliable option. However, data encryption is not built-in, and permanency is not guaranteed. Additionally, market volatility can impact storage costs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sia
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9xhyf5dmgbs22kwu4v7k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9xhyf5dmgbs22kwu4v7k.png" alt="Sia Ecosystem" width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sia's renter-host model impresses me, as it ensures data encryption, compression, and chunking across multiple computers. This network's blockchain regulates data storage, making it a secure option. I appreciate Sia's object-like storage format, similar to AWS's S3 bucket, which makes it easy to understand and work with.&lt;/p&gt;

&lt;h2&gt;
  
  
  Arweave
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1c2dsx7808nwejt4ydn0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1c2dsx7808nwejt4ydn0.png" alt="Arweave Ecosystem" width="800" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Arweave boasts permanency, which sets it apart from other networks. The ability to store data forever without worrying about removal or inaccessibility is a game-changer. I appreciate Arweave's decentralized platform for building applications, which ensures data permanency. While Arweave does offer encryption tools, data encryption is not a built-in feature of the network. This network has the potential to revolutionize the way we build and store data in dApps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/n1ElR218FeA" rel="noopener noreferrer"&gt;&lt;strong&gt;Check out our new Solidity-based course on YouTube to learn about NFT development, breeding, and more&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/n1ElR218FeA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;In conclusion, decentralized blockchain storage networks like Filecoin, Sia, and Arweave offer a reliable and cost-effective solution for storing data in dApps. By understanding how these networks work, you can incorporate them into your decentralized applications and take advantage of their benefits. Remember to check out their documentation and explore how they can enhance your dApp development journey.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;About the Author&lt;/strong&gt;&lt;br&gt;
Darlington Gospel is a seasoned blockchain developer and educator with over 8 years of experience. He specializes in blockchain development, fullstack software development, technical instruction, and content creation.&lt;/p&gt;

&lt;p&gt;We run a &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube channel called Dapp Mentors&lt;/strong&gt;&lt;/a&gt; where we share tutorials and tips on web3 development, and we regularly post articles online about the latest trends in the blockchain space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;About Dapp Mentors&lt;/strong&gt;&lt;br&gt;
Dapp Mentors is a community dedicated to helping developers transition into web3 development. Our team includes experienced blockchain developers and educators passionate about sharing their knowledge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For more information, contact us at:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/darlington-gospel-aa626b125/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://discord.gg/PgFDUVT6n9" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/iDaltonic" rel="noopener noreferrer"&gt;X-twitter&lt;/a&gt;&lt;br&gt;
&lt;a href="https://youtube.com/@dappmentors" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Website&lt;/a&gt;&lt;/p&gt;

</description>
      <category>web3</category>
      <category>dapps</category>
      <category>blockchain</category>
      <category>news</category>
    </item>
    <item>
      <title>Top Smart Contract Languages in 2024: Solidity, Rust, Motoko</title>
      <dc:creator>Darlington Gospel</dc:creator>
      <pubDate>Wed, 05 Jun 2024 18:10:28 +0000</pubDate>
      <link>https://dev.to/daltonic/top-smart-contract-languages-in-2024-solidity-rust-motoko-1i87</link>
      <guid>https://dev.to/daltonic/top-smart-contract-languages-in-2024-solidity-rust-motoko-1i87</guid>
      <description>&lt;p&gt;Welcome to Dapp Mentors! In this article, we'll delve into the top three programming languages for blockchain development: Solidity, Rust, and Motoko. As a seasoned blockchain developer and educator, I'll share my expertise to help you transition into web3 development.&lt;/p&gt;

&lt;p&gt;You can watch this article as a video below or continue reading through it.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/x6R-EYsjr20"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solidity: The Favorite&lt;/strong&gt;&lt;br&gt;
Solidity is our top choice due to its simplicity, ease of use, and wide community support. It's the most widely used language for blockchain development, and its simplicity makes it an excellent choice for beginners. However, it has limitations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scalability&lt;/strong&gt;: Solidity is not very scalable, especially on layer one. This limitation has led to the development of layer two solutions built on top of Ethereum.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security&lt;/strong&gt;: Solidity is not as secure as Rust. While it's widely adopted, its security vulnerabilities can be a concern.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flmmo2botld8gbz7pzaky.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flmmo2botld8gbz7pzaky.png" alt="Solidity Code Example" width="800" height="544"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In my opinion, Solidity is a great language for beginners, but its limitations make it less suitable for large-scale applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Top Companies Using Solidity&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ethereum&lt;/li&gt;
&lt;li&gt;Binance Smart Chain&lt;/li&gt;
&lt;li&gt;Polygon Network&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Watch our video on "Building a Simple Smart Contract with Solidity" to learn more about how to implement Solidity in your blockchain projects!&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/UbidE-tAibk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rust: The Secure and Scalable&lt;/strong&gt;&lt;br&gt;
Rust is a more mature language than Solidity, offering security and scalability. Its advantages include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Security&lt;/strong&gt;: Rust is a more secure language than Solidity, making it an excellent choice for high-stakes applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability&lt;/strong&gt;: Rust is highly scalable, making it suitable for large-scale blockchain applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wi55nudis0iuqwi6dus.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wi55nudis0iuqwi6dus.png" alt="Rust Code Example" width="751" height="909"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In my opinion, Rust is a powerful language that offers a great balance between security and scalability, making it an excellent choice for large-scale blockchain applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Top Companies Using Rust&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Solana&lt;/li&gt;
&lt;li&gt;Polkadot&lt;/li&gt;
&lt;li&gt;Stellar (uses Rust under the hood for their smart contract framework Soroban)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Motoko: The Newcomer&lt;/strong&gt;&lt;br&gt;
Motoko is exclusive to the Internet Computer Protocol (ICP) ecosystem. While it's highly scalable and performant, its adoption is limited, and it's relatively new. Its advantages include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scalability&lt;/strong&gt;: Motoko is highly scalable, making it suitable for large-scale blockchain applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ease of use&lt;/strong&gt;: Motoko is easy to learn and use, even for developers new to blockchain development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsnoxsm6fp0qlh0l8rmjh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsnoxsm6fp0qlh0l8rmjh.png" alt="Motoko Code Example" width="722" height="645"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In my opinion, Motoko is a promising language that offers a unique set of features and advantages. Still, its limited adoption and exclusive nature make it less versatile than Solidity and Rust.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In conclusion, each language has its strengths and weaknesses. Solidity is simple and widely adopted, Rust offers security and scalability, and Motoko is unique to ICP. Consider learning Rust for its versatility across blockchain networks. Join the conversation and share your thoughts on your favorite programming language and why you prefer it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;About the Author&lt;/strong&gt;&lt;br&gt;
Darlington Gospel is a seasoned blockchain developer and educator with over 8 years of experience. He specializes in blockchain development, fullstack software development, technical instruction, and content creation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;About Dapp Mentors&lt;/strong&gt;&lt;br&gt;
Dapp Mentors is a community dedicated to helping developers transition into web3 development. Our team includes experienced blockchain developers and educators passionate about sharing their knowledge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch our video on "Getting Started with Blockchain Development" to learn more about our community and resources!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/AKZ8mkR9XS0"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;For more information, contact us at:&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/darlington-gospel-aa626b125/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://discord.gg/PgFDUVT6n9" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/iDaltonic" rel="noopener noreferrer"&gt;X-twitter&lt;/a&gt;&lt;br&gt;
&lt;a href="https://youtube.com/@dappmentors" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Website&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>web3</category>
      <category>smartcontract</category>
      <category>dapp</category>
    </item>
    <item>
      <title>How to Build a Web3 Events Marketplace with Next.js, Typescript, and Solidity</title>
      <dc:creator>Darlington Gospel</dc:creator>
      <pubDate>Sun, 04 Feb 2024 14:52:41 +0000</pubDate>
      <link>https://dev.to/daltonic/how-to-build-a-web3-events-marketplace-with-nextjs-typescript-and-solidity-498h</link>
      <guid>https://dev.to/daltonic/how-to-build-a-web3-events-marketplace-with-nextjs-typescript-and-solidity-498h</guid>
      <description>&lt;p&gt;What you will be building, see our &lt;a href="https://github.com/Daltonic/dappEventX" rel="noopener noreferrer"&gt;git repo&lt;/a&gt; for the finished work and our &lt;a href="https://dapp-event-x.vercel.app/" rel="noopener noreferrer"&gt;live demo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxdzmuwag7kbehwgugnyt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxdzmuwag7kbehwgugnyt.png" alt="Events Marketplace" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegsgiwktfl5qjeby8zmm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegsgiwktfl5qjeby8zmm.png" alt="Events Marketplace" width="800" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Welcome to our comprehensive guide on "Building a Web3 Events Marketplace with Next.js, TypeScript, and Solidity". In this tutorial, we'll construct a decentralized Events Marketplace that harnesses the power of blockchain technology. You'll gain a clear understanding of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building dynamic interfaces with Next.js&lt;/li&gt;
&lt;li&gt;Crafting Ethereum smart contracts with Solidity&lt;/li&gt;
&lt;li&gt;Incorporating static type checking using TypeScript&lt;/li&gt;
&lt;li&gt;Deploying and interacting with your smart contracts&lt;/li&gt;
&lt;li&gt;Understanding the fundamentals of blockchain-based Events Marketplaces&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end of this guide, you'll have a functioning decentralized platform where users can list and participate in events, with all transactions managed and secured by Ethereum smart contracts.&lt;/p&gt;

&lt;p&gt;As an added incentive for participating in this tutorial, we're giving away a copy of our prestigious book on becoming an in-demand Solidity developer. This offer is free for the first 300 participants. For instructions on how to claim your copy, please watch the short video below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw474uw3rs0hh269y9h8e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw474uw3rs0hh269y9h8e.png" alt="Capturing Smart Contract Development" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;You will need the following tools installed to build along with me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;li&gt;Yarn&lt;/li&gt;
&lt;li&gt;Git Bash&lt;/li&gt;
&lt;li&gt;MetaMask&lt;/li&gt;
&lt;li&gt;Next.js&lt;/li&gt;
&lt;li&gt;Solidity&lt;/li&gt;
&lt;li&gt;Redux Toolkit&lt;/li&gt;
&lt;li&gt;Tailwind CSS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To set up MetaMask for this tutorial, please watch the instructional video below:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/qV1mbFOtkxo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Once you have successfully completed the setup, you are eligible to receive a free copy of our book. To claim your book, &lt;a href="https://forms.gle/uGtm3ZcEHb5pqd3YA" rel="noopener noreferrer"&gt;please fill out the form to submit your proof-of-work&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Watch the following &lt;a href="https://www.youtube.com/playlist?list=PLUDcVqFK2t-C36KaTMzV3y1wu8Hf-qyAI" rel="noopener noreferrer"&gt;instructional videos&lt;/a&gt; to receive up to 3-months of free premium courses on Dapp Mentors Academy, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dappmentors.org/courses/details/fullstack-nft-minting-course" rel="noopener noreferrer"&gt;Fullstack NFT Minting Course&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dappmentors.org/courses/details/fullstack-nft-marketplace-course" rel="noopener noreferrer"&gt;Fullstack NFT Marketplace Course&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dappmentors.org/courses/details/fullstack-blockchain-101-course" rel="noopener noreferrer"&gt;Fullstack Blockchain Course&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Join the Bitfinity ecosystem and be a part of the next generation of dApps. Apply your Bitfinity knowledge to create a Blockchain-based House Rental dApp in the final module. &lt;a href="https://bitfinity.network/" rel="noopener noreferrer"&gt;&lt;strong&gt;Deploy your smart contracts to the Bitfinity network and revolutionize the rental industry&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With that said, let’s jump into the tutorial and set up our project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;We'll start by cloning a prepared frontend repository and setting up the environment variables. Run the following commands:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/Daltonic/dappEventX
cd dappEventX
yarn install
git checkout 01_no_redux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Next, create a &lt;code&gt;.env&lt;/code&gt; file at the root of the project and include the following keys:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NEXT_PUBLIC_RPC_URL=http://127.0.0.1:8545
NEXT_PUBLIC_ALCHEMY_ID=&amp;lt;YOUR_ALCHEMY_PROJECT_ID&amp;gt;
NEXT_PUBLIC_PROJECT_ID=&amp;lt;WALLET_CONNECT_PROJECT_ID&amp;gt;
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=somereallysecretsecret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Replace &lt;code&gt;&amp;lt;YOUR_ALCHEMY_PROJECT_ID&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;WALLET_CONNECT_PROJECT_ID&amp;gt;&lt;/code&gt; with your respective project IDs. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;YOUR_ALCHEMY_PROJECT_ID&lt;/code&gt;: &lt;a href="https://dashboard.alchemy.com/" rel="noopener noreferrer"&gt;Get Key Here&lt;/a&gt; &lt;br&gt;
&lt;code&gt;WALLET_CONNECT_PROJECT_ID&lt;/code&gt;: &lt;a href="https://cloud.walletconnect.com/sign-in" rel="noopener noreferrer"&gt;Get Key Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, run &lt;code&gt;yarn dev&lt;/code&gt; to start the project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyovxo4b3g3z5d1wqjq88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyovxo4b3g3z5d1wqjq88.png" alt="Dummy Data" width="800" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our user interface is prepared to incorporate smart contracts, however, we still need to integrate Redux in order to facilitate the sharing of data.&lt;/p&gt;
&lt;h2&gt;
  
  
  Building the Redux Store
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flf44vv3zla7m78501mb4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flf44vv3zla7m78501mb4.png" alt="Store Structure" width="800" height="217"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above image represents the structure of our Redux store, it will be simple since we are not creating some overly complex project.&lt;/p&gt;

&lt;p&gt;We'll set up Redux to manage our application's global state. Follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;store&lt;/code&gt; folder at the project root.&lt;/li&gt;
&lt;li&gt;Inside &lt;code&gt;store&lt;/code&gt;, create two folders: &lt;code&gt;actions&lt;/code&gt; and &lt;code&gt;states&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Inside &lt;code&gt;states&lt;/code&gt;, create a &lt;code&gt;globalStates.ts&lt;/code&gt; file.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Inside &lt;code&gt;actions&lt;/code&gt;, create a &lt;code&gt;globalActions.ts&lt;/code&gt; file.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;globalSlices.ts&lt;/code&gt; file inside the &lt;code&gt;store&lt;/code&gt; folder.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Create an &lt;code&gt;index.ts&lt;/code&gt; file inside the &lt;code&gt;store&lt;/code&gt; folder.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Update the &lt;code&gt;pages/_app.tsx&lt;/code&gt; file with the Redux provider.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We have implemented Redux toolkit in our application and plan to revisit its usage when integrating the backend with the frontend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Smart Contract Development
&lt;/h2&gt;

&lt;p&gt;Next, we'll develop the smart contract for our platform:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;contracts&lt;/code&gt; folder at the project root.&lt;/li&gt;
&lt;li&gt;Inside &lt;code&gt;contracts&lt;/code&gt;, create a &lt;code&gt;DappEventX.sol&lt;/code&gt; file and add the contract code below.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The above smart contract is designed to manage an Events Marketplace on the blockchain. It allows users to create, update, and delete events, buy tickets for events, and handle payouts. Here's a detailed breakdown of its functions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Constructor (&lt;/strong&gt;&lt;code&gt;**constructor(uint256 _pct) ERC721('Event X', 'EVX')**&lt;/code&gt;&lt;strong&gt;):&lt;/strong&gt; This function initializes the contract, sets the service fee percentage, and assigns initial token parameters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;createEvent Function:&lt;/strong&gt; This function allows a user to create a new event. It requires the title, description, image URL, capacity, ticket cost, and start and end times. It validates all input data and creates a new event structure, which is stored in the events mapping.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;updateEvent Function:&lt;/strong&gt; This function allows a user to update an existing event. It requires the same parameters as the createEvent function. It checks that the event exists and that the caller is the owner of the event before updating the event data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;deleteEvent Function:&lt;/strong&gt; This function allows the owner of an event to delete it. It checks that the event exists, that the caller is the owner of the event or the contract owner, and that the event has not been paid out or refunded. It then refunds all tickets for the event and marks the event as deleted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getEvents Function:&lt;/strong&gt; This function returns all existing events. It creates an array of the right size, then fills it with all events that have not been deleted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getMyEvents Function:&lt;/strong&gt; This function returns all events owned by the caller. It creates an array of the right size, then fills it with all events owned by the caller that have not been deleted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getSingleEvent Function:&lt;/strong&gt; This function returns a specific event. It simply returns the event structure from the events mapping.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;buyTickets Function:&lt;/strong&gt; This function allows a user to buy tickets for an event. It checks that the event exists, that the sent value is at least the total cost of the tickets, and that there are enough seats available. It then creates new ticket structures for each ticket and adds them to the tickets mapping.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getTickets Function:&lt;/strong&gt; This function returns all tickets for a specific event. It simply returns the array of ticket structures from the tickets mapping.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;refundTickets Function:&lt;/strong&gt; This internal function refunds all tickets for a specific event. It marks each ticket as refunded, sends the ticket cost back to the ticket owner, and decreases the contract balance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;payout Function:&lt;/strong&gt; This function handles payout distribution at the end of an event. It checks that the event exists, has not already been paid out, and is no longer ongoing. It then mints tickets for the event, calculates the revenue and fee, and sends the revenue minus the fee to the event owner and the fee to the contract owner. It marks the event as paid out and decreases the contract balance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;mintTickets Function:&lt;/strong&gt; This internal function mints tickets for a specific event. It marks each ticket and the event as minted, and mints a new ERC721 token for each ticket.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;payTo Function:&lt;/strong&gt; This internal function sends funds to a specified address. It uses the low-level call function to send the funds and checks that the call was successful.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;currentTime Function:&lt;/strong&gt; This internal function returns the current timestamp. It uses the block.timestamp global variable, multiplies it by 1000, and adds 1000.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Contract Deployment and Seeding
&lt;/h2&gt;

&lt;p&gt;Now, let's deploy our smart contract and populate it with some dummy data:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;scripts&lt;/code&gt; folder at the project root.&lt;/li&gt;
&lt;li&gt;Inside &lt;code&gt;scripts&lt;/code&gt;, create a &lt;code&gt;deploy.js&lt;/code&gt; and a &lt;code&gt;seed.js&lt;/code&gt; file and add the following codes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Deploy Script&lt;/strong&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Seed&lt;/strong&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Run the following commands to deploy the contract and seed it with data:&lt;/p&gt;

&lt;p&gt;yarn hardhat node # Run in terminal 1&lt;br&gt;
yarn hardhat run scripts/deploy.js # Run in terminal 2&lt;br&gt;
yarn hardhat run scripts/seed.js # Run in terminal 2&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you did that correctly, you should see a similar output like the one below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fjsb0x1bcugf2sqnjdx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fjsb0x1bcugf2sqnjdx.png" alt="Deployment" width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point we can start the integration of our smart contract to our frontend.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/JePa-DzZsJA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Frontend Integration
&lt;/h2&gt;

&lt;p&gt;First, create a &lt;code&gt;services&lt;/code&gt; folder at the project root, and inside it, create a &lt;code&gt;blockchain.tsx&lt;/code&gt; file. This file will contain functions to interact with our smart contract.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The above code is a service that interacts with a Events Marketplace contract. The service interacts with a smart contract deployed on the Ethereum blockchain using the ethers.js library. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here's a detailed breakdown of its functions:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getEthereumContracts Function:&lt;/strong&gt; This function sets up a connection to the Ethereum blockchain and the smart contract. It uses the ethers library to create a provider (to interact with the Ethereum blockchain) and a signer (to sign transactions). Then, it creates a contract instance that can be used to interact with the smart contract.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;createEvent Function:&lt;/strong&gt; This function creates a new event by calling the createEvent function of the contract.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;updateEvent Function:&lt;/strong&gt; This function updates an existing event by calling the updateEvent function of the contract.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;deleteEvent Function:&lt;/strong&gt; This function deletes an event by calling the deleteEvent function of the contract.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;payout Function:&lt;/strong&gt; This function handles payout distribution at the end of an event.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;buyTicket Function:&lt;/strong&gt; This function allows a user to buy tickets for an event.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getEvents and getMyEvents Functions:&lt;/strong&gt; These functions retrieve information about all events or the events owned by the caller. They call the corresponding functions in the contract and structure the returned data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getEvent Function:&lt;/strong&gt; This function retrieves information about a specific event. It calls the corresponding function in the contract and structures the returned data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getTickets Function:&lt;/strong&gt; This function retrieves information about the tickets for a specific event. It calls the corresponding function in the contract and structures the returned data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;structuredEvent and structuredTicket Functions:&lt;/strong&gt; These functions structure the data returned from the contract into a more manageable format. They convert the data types from the contract's format to JavaScript's format and sort the data.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Next, update the &lt;code&gt;provider.tsx&lt;/code&gt; file inside &lt;code&gt;services&lt;/code&gt; to include the &lt;code&gt;bitfinity&lt;/code&gt; network using the following codes.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Page Interacting with Smart Contract
&lt;/h2&gt;

&lt;p&gt;Next, we'll link the functions in the blockchain service to their respective interfaces in the frontend:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No 1:  Displaying Available Events&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/index.tsx&lt;/code&gt; to get data from the &lt;code&gt;getEvents()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Take a moment and observe how we implemented the load more button, I bet you’ll find it useful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No 2:  Displaying User’s Events&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/events/personal.tsx&lt;/code&gt; to get data from the &lt;code&gt;getMyEvents()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 3:  Creating New Event&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/events/create.tsx&lt;/code&gt; to use the &lt;code&gt;createEvent()&lt;/code&gt; function for form submission..&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 4:  Displaying Single Event&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/events/[id].tsx&lt;/code&gt; to get data from the &lt;code&gt;getEvent()&lt;/code&gt; and &lt;code&gt;getTickets()&lt;/code&gt; functions.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 5:  Editing a Single Event&lt;/strong&gt;&lt;br&gt;
Change &lt;code&gt;pages/events/edit/[id].tsx&lt;/code&gt; to retrieve data from the &lt;code&gt;getEvent()&lt;/code&gt; and update by calling &lt;code&gt;updateEvent()&lt;/code&gt;.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 6:  Displaying Event Tickets&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/events/tickets/[id].tsx&lt;/code&gt; to retrieve data from the &lt;code&gt;getTickets()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Components with Smart Contract
&lt;/h2&gt;

&lt;p&gt;Let's apply the same approach we used for the previous pages and update the following components to interact with the smart contract.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No 1: Purchasing Ticket&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;components/BuyTicket.tsx&lt;/code&gt; file to use the &lt;code&gt;handleSubmit()&lt;/code&gt; function to call the &lt;code&gt;buyTicket()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 2: Deleting and Paying out Events&lt;/strong&gt;&lt;br&gt;
Lastly, update &lt;code&gt;components/EventAction.tsx&lt;/code&gt; file to use the &lt;code&gt;deleteEvent()&lt;/code&gt; and &lt;code&gt;payout()&lt;/code&gt; functions.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;It should be noted that this component is a dropdown and contains the relevant actions for managing a specific event.&lt;/p&gt;

&lt;p&gt;All the components and pages of the project have been successfully connected to the smart contract, indicating the completion of the project after implementing these updates.&lt;/p&gt;

&lt;p&gt;If your Next.js server was offline, you can bring it back up by executing the command &lt;code&gt;yarn dev&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For further learning, we recommends subscribing to our &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube channel&lt;/strong&gt;&lt;/a&gt; and &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;&lt;strong&gt;visiting our website for additional resources&lt;/strong&gt;&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Ubom39y5jX8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;In this tutorial, we have successfully built a Web3 Events Marketplace using Next.js, TypeScript, and Solidity. We've established the development environment, constructed the Redux store, and deployed our smart contract to our local chain. &lt;/p&gt;

&lt;p&gt;We've created dynamic interfaces, crafted Ethereum smart contracts, and managed shared data with Redux. By integrating the smart contract with the frontend, we've enabled users to list and participate in events, with transactions managed and secured by Ethereum smart contracts. &lt;/p&gt;

&lt;p&gt;Now, you're equipped with the skills to build your own Web3 Events Marketplace. We've also provided you with a live demo and the finished work in our git repo for reference. Happy coding!&lt;/p&gt;

&lt;h2&gt;
  
  
  About Author
&lt;/h2&gt;

&lt;p&gt;I am a web3 developer and the founder of &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Dapp Mentors&lt;/a&gt;, a company that helps businesses and individuals build and launch decentralized applications. I have over 7 years of experience in the software industry, and I am passionate about using blockchain technology to create new and innovative applications. I run a &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube channel called Dapp Mentors&lt;/strong&gt;&lt;/a&gt; where I share tutorials and tips on web3 development, and I regularly post articles online about the latest trends in the blockchain space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stay connected with us, join communities on&lt;/strong&gt;&lt;br&gt;
Discord: &lt;a href="https://discord.gg/PgFDUVT6n9" rel="noopener noreferrer"&gt;Join&lt;/a&gt;&lt;br&gt;
X-Twitter: &lt;a href="https://twitter.com/iDaltonic" rel="noopener noreferrer"&gt;Follow&lt;/a&gt;&lt;br&gt;
LinkedIn: &lt;a href="https://www.linkedin.com/company/dapp-mentors" rel="noopener noreferrer"&gt;Connect&lt;/a&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/Daltonic" rel="noopener noreferrer"&gt;Explore&lt;/a&gt;&lt;br&gt;
Website: &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Visit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dapps</category>
      <category>web3</category>
      <category>nextjs</category>
      <category>solidity</category>
    </item>
    <item>
      <title>How to Build a Web3 Play-To-Earn Platform with Next.js, Typescript, and Solidity</title>
      <dc:creator>Darlington Gospel</dc:creator>
      <pubDate>Sun, 28 Jan 2024 13:42:52 +0000</pubDate>
      <link>https://dev.to/daltonic/how-to-build-a-web3-play-to-earn-platform-with-nextjs-typescript-and-solidity-3l5k</link>
      <guid>https://dev.to/daltonic/how-to-build-a-web3-play-to-earn-platform-with-nextjs-typescript-and-solidity-3l5k</guid>
      <description>&lt;p&gt;What you will be building, see our &lt;a href="https://github.com/Daltonic/play2earnX" rel="noopener noreferrer"&gt;git repo&lt;/a&gt; for the finished work and our &lt;a href="https://play2earn-x.vercel.app/" rel="noopener noreferrer"&gt;live demo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyis1sohxllgoqfvhsc0e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyis1sohxllgoqfvhsc0e.png" alt="Play2EarnX" width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn8kxov7p3ot5rfbusdjj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn8kxov7p3ot5rfbusdjj.png" alt="Play2EarnX" width="800" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Welcome to our comprehensive guide on "Building a Web3 Play-To-Earn Platform with Next.js, Typescript, and Solidity". In this tutorial, we'll build a decentralized Play-To-Earn platform that leverages the power of blockchain technology. You'll gain a clear understanding of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building dynamic interfaces with Next.js&lt;/li&gt;
&lt;li&gt;Crafting Ethereum smart contracts with Solidity&lt;/li&gt;
&lt;li&gt;Incorporating static type checking using TypeScript&lt;/li&gt;
&lt;li&gt;Deploying and interacting with your smart contracts&lt;/li&gt;
&lt;li&gt;Understanding the fundamentals of blockchain-based Play-To-Earn platforms&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end of this guide, you'll have a functioning decentralized platform where users can participate in Play-To-Earn games, with all activities managed and secured by Ethereum smart contracts.&lt;/p&gt;

&lt;p&gt;As an added incentive for participating in this tutorial, we're giving away a copy of our prestigious book on becoming an in-demand Solidity developer. This offer is free for the first 300 participants. For instructions on how to claim your copy, please watch the short video below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw474uw3rs0hh269y9h8e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw474uw3rs0hh269y9h8e.png" alt="Capturing Smart Contract Development" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;You will need the following tools installed to build along with me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;li&gt;Yarn&lt;/li&gt;
&lt;li&gt;Git Bash&lt;/li&gt;
&lt;li&gt;MetaMask&lt;/li&gt;
&lt;li&gt;Next.js&lt;/li&gt;
&lt;li&gt;Solidity&lt;/li&gt;
&lt;li&gt;Redux Toolkit&lt;/li&gt;
&lt;li&gt;Tailwind CSS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To set up MetaMask for this tutorial, please watch the instructional video below:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/qV1mbFOtkxo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Once you have successfully completed the setup, you are eligible to receive a free copy of our book. To claim your book, &lt;a href="https://forms.gle/uGtm3ZcEHb5pqd3YA" rel="noopener noreferrer"&gt;please fill out the form to submit your proof-of-work&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Watch the following &lt;a href="https://www.youtube.com/playlist?list=PLUDcVqFK2t-C36KaTMzV3y1wu8Hf-qyAI" rel="noopener noreferrer"&gt;&lt;strong&gt;instructional videos&lt;/strong&gt;&lt;/a&gt; to receive up to 3-months of free premium courses on Dapp Mentors Academy, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dappmentors.org/courses/details/fullstack-nft-minting-course" rel="noopener noreferrer"&gt;Fullstack NFT Minting Course&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dappmentors.org/courses/details/fullstack-nft-marketplace-course" rel="noopener noreferrer"&gt;Fullstack NFT Marketplace Course&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dappmentors.org/courses/details/fullstack-blockchain-101-course" rel="noopener noreferrer"&gt;Fullstack Blockchain Course&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ready to take your Bitfinity skills to the next level? Dive into the intricacies of smart contract development on ICP as you build a Ticketing Management System in the upcoming module. &lt;a href="https://bitfinity.network/" rel="noopener noreferrer"&gt;&lt;strong&gt;Create, deploy, and manage your smart contracts on the Bitfinity network.&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With that said, let’s jump into the tutorial and set up our project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;We'll start by cloning a prepared frontend repository and setting up the environment variables. Run the following commands:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/Daltonic/play2earnX
cd play2earnX
yarn install
git checkout 01_no_redux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Next, create a &lt;code&gt;.env&lt;/code&gt; file at the root of the project and include the following keys:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NEXT_PUBLIC_RPC_URL=http://127.0.0.1:8545
NEXT_PUBLIC_ALCHEMY_ID=&amp;lt;YOUR_ALCHEMY_PROJECT_ID&amp;gt;
NEXT_PUBLIC_PROJECT_ID=&amp;lt;WALLET_CONNECT_PROJECT_ID&amp;gt;
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=somereallysecretsecret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Replace &lt;code&gt;&amp;lt;YOUR_ALCHEMY_PROJECT_ID&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;WALLET_CONNECT_PROJECT_ID&amp;gt;&lt;/code&gt; with your respective project IDs. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;YOUR_ALCHEMY_PROJECT_ID&lt;/code&gt;: &lt;a href="https://dashboard.alchemy.com/" rel="noopener noreferrer"&gt;Get Key Here&lt;/a&gt; &lt;br&gt;
&lt;code&gt;WALLET_CONNECT_PROJECT_ID&lt;/code&gt;: &lt;a href="https://cloud.walletconnect.com/sign-in" rel="noopener noreferrer"&gt;Get Key Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, run &lt;code&gt;yarn dev&lt;/code&gt; to start the project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhyw7pgq4ji04kphfoxg7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhyw7pgq4ji04kphfoxg7.png" alt="Dummy Data" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our user interface is prepared to incorporate smart contracts, however, we still need to integrate Redux in order to facilitate the sharing of data.&lt;/p&gt;
&lt;h2&gt;
  
  
  Building the Redux Store
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flf44vv3zla7m78501mb4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flf44vv3zla7m78501mb4.png" alt="Store Structure" width="800" height="217"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above image represents the structure of our Redux store, it will be simple since we are not creating some overly complex project.&lt;/p&gt;

&lt;p&gt;We'll set up Redux to manage our application's global state. Follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;store&lt;/code&gt; folder at the project root.&lt;/li&gt;
&lt;li&gt;Inside &lt;code&gt;store&lt;/code&gt;, create two folders: &lt;code&gt;actions&lt;/code&gt; and &lt;code&gt;states&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Inside &lt;code&gt;states&lt;/code&gt;, create a &lt;code&gt;globalStates.ts&lt;/code&gt; file.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Inside &lt;code&gt;actions&lt;/code&gt;, create a &lt;code&gt;globalActions.ts&lt;/code&gt; file.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;globalSlices.ts&lt;/code&gt; file inside the &lt;code&gt;store&lt;/code&gt; folder.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Create an &lt;code&gt;index.ts&lt;/code&gt; file inside the &lt;code&gt;store&lt;/code&gt; folder.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Update the &lt;code&gt;pages/_app.tsx&lt;/code&gt; file with the Redux provider.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We have implemented Redux toolkit in our application and plan to revisit its usage when integrating the backend with the frontend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Smart Contract Development
&lt;/h2&gt;

&lt;p&gt;Next, we'll develop the smart contract for our platform:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;contracts&lt;/code&gt; folder at the project root.&lt;/li&gt;
&lt;li&gt;Inside &lt;code&gt;contracts&lt;/code&gt;, create a &lt;code&gt;PlayToEarnX.sol&lt;/code&gt; file and add the contract code below.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The above smart contract is a Play-To-Earn (P2E) gaming platform, which is created with Solidity. The contract integrates features such as game creation, player invitations, score recording, and payout distribution. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here's a breakdown of its logic, function by function:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Constructor (&lt;/strong&gt;&lt;code&gt;**constructor(uint256 _pct) ERC20('Play To Earn', 'P2E')**&lt;/code&gt;&lt;strong&gt;):&lt;/strong&gt; This function initializes the contract. It sets the service fee percentage and assigns initial token parameters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;createGame Function:&lt;/strong&gt; This function allows a user to create a new game, specifying the title, description, number of participants, number of winners, start date, and end date. It requires a stake greater than zero and validates all input data. A new game and score structure are created and stored in their respective mappings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;deleteGame Function:&lt;/strong&gt; This function allows the owner of a game to delete it, provided no participants have joined. It refunds the stake to the game owner and marks the game as deleted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;playedSaved Function:&lt;/strong&gt; This function is an internal function that creates a new player for a game. It increments the total players count, adds the new player to the players mapping, and increases the game's acceptees count.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;invitePlayer Function:&lt;/strong&gt; This function allows a user to invite another player to a game. It checks if the game exists and if there is room for more players. An invitation is then created and added to the invitationsOf mapping.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;acceptInvitation Function:&lt;/strong&gt; This function allows a user to accept an invitation to a game, provided they send enough funds to cover the game's stake. It creates a new player for the game and updates the invitation status.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;rejectInvitation Function:&lt;/strong&gt; This function allows a user to reject an invitation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;payout Function:&lt;/strong&gt; This function handles the payout distribution at the end of a game. It checks if the game has ended and if it has not already been paid out. It calculates the total stakes, platform fee, creator fee, and game revenue. It pays out the platform fee to the contract owner, the creator fee to the game owner, and distributes the game revenue among the winners. It also mints new tokens for the winners.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;sortScores Function:&lt;/strong&gt; This function sorts players based on their scores. It uses a simple bubble sort algorithm with a twist: it also takes into account whether a player has played the game or not. Players who have not played are sorted to the bottom.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;saveScore Function:&lt;/strong&gt; This function allows a player to save their score for a game. It validates the game and player, then updates the player's score.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;setFeePercent Function:&lt;/strong&gt; This function allows the contract owner to change the service fee percentage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getGames, getPaidOutGames, getMyGames Functions:&lt;/strong&gt; These functions return lists of games based on different criteria (all games, games that have been paid out, and games owned by the caller).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getGame Function:&lt;/strong&gt; This function returns the details of a specific game.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getInvitations Function:&lt;/strong&gt; This function returns all invitations for a specific game.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getMyInvitations Function:&lt;/strong&gt; This function returns all invitations received by the caller.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getScores Function:&lt;/strong&gt; This function returns all scores for a specific game.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;payTo Function:&lt;/strong&gt; This internal function sends funds to a specified address.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;currentTime Function:&lt;/strong&gt; This internal function returns the current timestamp.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Contract Deployment and Seeding
&lt;/h2&gt;

&lt;p&gt;Now, let's deploy our smart contract and populate it with some dummy data:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;scripts&lt;/code&gt; folder at the project root.&lt;/li&gt;
&lt;li&gt;Inside &lt;code&gt;scripts&lt;/code&gt;, create a &lt;code&gt;deploy.js&lt;/code&gt; and a &lt;code&gt;seed.js&lt;/code&gt; file and add the following codes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Deploy Script&lt;/strong&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Seed&lt;/strong&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Run the following commands to deploy the contract and seed it with data:&lt;/p&gt;

&lt;p&gt;yarn hardhat node # Run in terminal 1&lt;br&gt;
yarn hardhat run scripts/deploy.js # Run in terminal 2&lt;br&gt;
yarn hardhat run scripts/seed.js # Run in terminal 2&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you did that correctly, you should see a similar output like the one below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fjsb0x1bcugf2sqnjdx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fjsb0x1bcugf2sqnjdx.png" alt="Deployment" width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point we can start the integration of our smart contract to our frontend.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/fJIiqeevqoU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Frontend Integration
&lt;/h2&gt;

&lt;p&gt;First, create a &lt;code&gt;services&lt;/code&gt; folder at the project root, and inside it, create a &lt;code&gt;blockchain.tsx&lt;/code&gt; file. This file will contain functions to interact with our smart contract.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The above code is a service that interacts with our Play-To-Earn gaming smart contract on the chain. It uses the &lt;code&gt;Ethers.js&lt;/code&gt; library to interact with the Ethereum blockchain for contract interaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here's a detailed breakdown of its functions:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getEthereumContracts Function:&lt;/strong&gt; This function sets up a connection to the Ethereum blockchain and the smart contract. It uses the ethers library to create a provider (to interact with the Ethereum blockchain) and a signer (to sign transactions). Then, it creates a contract instance that can be used to interact with the smart contract.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getOwner Function:&lt;/strong&gt; This function retrieves the owner of the contract. It calls the owner function of the contract, which is defined in the OpenZeppelin's Ownable contract.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getGames, getMyGames, getGame Functions:&lt;/strong&gt; These functions retrieve information about the games. They call the corresponding functions in the contract and structure the returned data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getInvitations, getMyInvitations Functions:&lt;/strong&gt; These functions retrieve information about the game invitations. They call the corresponding functions in the contract and structure the returned data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getScores Function:&lt;/strong&gt; This function retrieves scores of a game. It calls the corresponding function in the contract and structures the returned data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;createGame Function:&lt;/strong&gt; This function creates a new game by calling the createGame function of the contract. It checks if the browser provider is installed and handles any errors that might occur.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;deleteGame Function:&lt;/strong&gt; This function deletes a game by calling the deleteGame function of the contract. It checks if the browser provider is installed and handles any errors that might occur.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;invitePlayer Function:&lt;/strong&gt; This function invites a player to a game by calling the invitePlayer function of the contract. It checks if the browser provider is installed and handles any errors that might occur.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;saveScore Function:&lt;/strong&gt; This function saves a player's score by calling the saveScore function of the contract. It checks if the browser provider is installed and handles any errors that might occur.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;payout Function:&lt;/strong&gt; This function handles payout distribution by calling the payout function of the contract. It checks if the browser provider is installed and handles any errors that might occur.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;respondToInvite Function:&lt;/strong&gt; This function allows a user to respond to an invitation by calling either the acceptInvitation or rejectInvitation function of the contract, based on the user's response. It checks if the browser provider is installed and handles any errors that might occur.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;structuredGames, structuredInvitations, structuredScores Functions:&lt;/strong&gt; These functions structure the data returned from the contract into a more manageable format. They convert the data types from the contract's format to JavaScript's format and sort the data.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Next, update the &lt;code&gt;provider.tsx&lt;/code&gt; file inside &lt;code&gt;services&lt;/code&gt; to include the &lt;code&gt;bitfinity&lt;/code&gt; network using the following codes.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Page Interacting with Smart Contract
&lt;/h2&gt;

&lt;p&gt;Next, we'll link the functions in the blockchain service to their respective interfaces in the frontend:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No 1:  Displaying Available Games&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/index.tsx&lt;/code&gt; to get data from the &lt;code&gt;getGames()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 2:  Displaying User’s Games&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/games.tsx&lt;/code&gt; to get data from the &lt;code&gt;getMyGames()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Notice how we combined &lt;code&gt;useEffect()&lt;/code&gt; to dispatch the games into the store before rendering on screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No 3:  Displaying User’s Invitations&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/invitations.tsx&lt;/code&gt; to get data from the &lt;code&gt;getMyInvitations()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We also combined &lt;code&gt;useEffect()&lt;/code&gt; to dispatch the invitations into the store before rendering on screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No 4: Displaying Game Invitations&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/invitations/[id].tsx&lt;/code&gt; to use the &lt;code&gt;getServerSideProps()&lt;/code&gt;, &lt;code&gt;getGame()&lt;/code&gt;, and &lt;code&gt;getInvitations()&lt;/code&gt; to retrieve a game invitations by specifying the game Id.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 5: Showcasing a Gameplay&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/gameplay/[id].tsx&lt;/code&gt; to use the &lt;code&gt;getServerSideProps()&lt;/code&gt;, &lt;code&gt;getGame()&lt;/code&gt;, and &lt;code&gt;getScores()&lt;/code&gt; to retrieve a game players by specifying the game Id.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The script mentioned above is the core of the frontend code for this page. It contains the necessary functions and behaviors to create a memory game where users can compete against each other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No 6: Displaying Game Result&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/results/[id].tsx&lt;/code&gt; to use the &lt;code&gt;getServerSideProps()&lt;/code&gt;, &lt;code&gt;getGame()&lt;/code&gt;, and &lt;code&gt;getScores()&lt;/code&gt; to retrieve a game score by specifying the game Id.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;It's worth mentioning that users can make a payout from this page after the game duration has ended.&lt;/p&gt;

&lt;h2&gt;
  
  
  Components with Smart Contract
&lt;/h2&gt;

&lt;p&gt;Let's apply the same approach we used for the previous pages and update the following components to interact with the smart contract.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No 1: Creating New Games&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;components/CreateGame.tsx&lt;/code&gt; file to use the &lt;code&gt;handleGameCreation()&lt;/code&gt; function to call the &lt;code&gt;createGame()&lt;/code&gt; function for form submission.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 2: Handling Game Deletion&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;components/GameActions.tsx&lt;/code&gt; file to use the &lt;code&gt;handleDelete()&lt;/code&gt; function to call the &lt;code&gt;deleteGame()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 3: Displaying Game Details Modal&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;components/GameDetails.tsx&lt;/code&gt; file to use the &lt;code&gt;closeModal()&lt;/code&gt; function to call the &lt;code&gt;setResultModal()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 4: Inviting Players&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;components/GameInvitation.tsx&lt;/code&gt; file to use the &lt;code&gt;handleResponse()&lt;/code&gt; function to call the &lt;code&gt;respondToInvite()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 5: Launching Game Details Modal&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;components/GameList.tsx&lt;/code&gt; file to use the &lt;code&gt;openModal()&lt;/code&gt; function to call the &lt;code&gt;setResultModal()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Please note that this &lt;code&gt;setResultModal()&lt;/code&gt; function actually launches the game details modal, that’s a little oversight in function name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No 6: Launching the Create Game Modal&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;components/Hero.tsx&lt;/code&gt; file to &lt;code&gt;dispatch&lt;/code&gt; the &lt;code&gt;setCreateModal()&lt;/code&gt; function, this will help us launch the create game form modal.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 7: Launching the Invite Modal&lt;/strong&gt;&lt;br&gt;
Lastly, update &lt;code&gt;components/InviteModal.tsx&lt;/code&gt; file to use the &lt;code&gt;sendInvitation()&lt;/code&gt;  function to call the &lt;code&gt;invitePlayer()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The project is now complete as all components and pages are connected to the smart contract through the implementation of these updates.&lt;/p&gt;

&lt;p&gt;If your Next.js server was offline, you can bring it back up by executing the command &lt;code&gt;**yarn dev**&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For further learning, we recommends watch the full video of this build on our &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube channel&lt;/strong&gt;&lt;/a&gt; and &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;&lt;strong&gt;visiting our website for additional resources&lt;/strong&gt;&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/zi_6RWkOB1w"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;In this tutorial, we've successfully built a decentralized Play-To-Earn platform using Next.js, TypeScript, and Solidity. We've established the development environment, constructed the Redux store, and deployed our smart contract to our local chain. &lt;/p&gt;

&lt;p&gt;By merging the smart contract with the frontend, we've ensured a seamless gaming experience. This guide has equipped you with the skills to create dynamic interfaces, craft Ethereum smart contracts, manage shared data with Redux, and interact with smart contracts from the frontend. Now, you're ready to create your own Web3 Play-To-Earn platform. Happy coding!&lt;/p&gt;

&lt;h2&gt;
  
  
  About Author
&lt;/h2&gt;

&lt;p&gt;I am a web3 developer and the founder of &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Dapp Mentors&lt;/a&gt;, a company that helps businesses and individuals build and launch decentralized applications. I have over 7 years of experience in the software industry, and I am passionate about using blockchain technology to create new and innovative applications. I run a &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube channel called Dapp Mentors&lt;/strong&gt;&lt;/a&gt; where I share tutorials and tips on web3 development, and I regularly post articles online about the latest trends in the blockchain space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stay connected with us, join communities on&lt;/strong&gt;&lt;br&gt;
Discord: &lt;a href="https://discord.gg/PgFDUVT6n9" rel="noopener noreferrer"&gt;Join&lt;/a&gt;&lt;br&gt;
X-Twitter: &lt;a href="https://twitter.com/iDaltonic" rel="noopener noreferrer"&gt;Follow&lt;/a&gt;&lt;br&gt;
LinkedIn: &lt;a href="https://www.linkedin.com/company/dapp-mentors" rel="noopener noreferrer"&gt;Connect&lt;/a&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/Daltonic" rel="noopener noreferrer"&gt;Explore&lt;/a&gt;&lt;br&gt;
Website: &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Visit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>web3</category>
      <category>dapp</category>
      <category>nextjs</category>
      <category>solidity</category>
    </item>
    <item>
      <title>How to Build a Decentralized House Rental Platform with Next.js, Redux, and Solidity</title>
      <dc:creator>Darlington Gospel</dc:creator>
      <pubDate>Sun, 21 Jan 2024 08:57:15 +0000</pubDate>
      <link>https://dev.to/daltonic/how-to-build-a-decentralized-house-rental-platform-with-nextjs-redux-and-solidity-329a</link>
      <guid>https://dev.to/daltonic/how-to-build-a-decentralized-house-rental-platform-with-nextjs-redux-and-solidity-329a</guid>
      <description>&lt;p&gt;What you will be building, see the &lt;a href="https://dapp-bnb-x.vercel.app/" rel="noopener noreferrer"&gt;live demo&lt;/a&gt; at Bitfinity test network and the &lt;a href="https://github.com/Daltonic/dappBnbX" rel="noopener noreferrer"&gt;git repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz5s0kdwle0kwdgiz912j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz5s0kdwle0kwdgiz912j.png" alt="House Rental Marketplace" width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjddckbzgrqm7lki54tj8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjddckbzgrqm7lki54tj8.png" alt="House Rental Marketplace" width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Welcome to our second comprehensive guide on “Building a Decentralized House Rental Platform with Next.js, Redux, and Solidity”. We'll be developing a Decentralized House Rental Platform using Next.js, Solidity, and TypeScript. Throughout this tutorial, you'll gain a clear understanding of the following:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Building dynamic interfaces with Next.js
- Crafting Ethereum smart contracts with Solidity
- Incorporating static type checking using TypeScript
- Deploying and interacting with your smart contracts
- Understanding the fundamentals of blockchain-based rental platforms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;By the end of this guide, you will have a functioning decentralized platform where users can list and rent houses, all managed and secured by Ethereum smart contracts.&lt;/p&gt;

&lt;p&gt;As an added incentive for participating in this tutorial, we're giving away a copy of our prestigious book on becoming an in-demand Solidity developer. This offer is free for the first 300 participants. For instructions on how to claim your copy, please watch the short video below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw474uw3rs0hh269y9h8e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw474uw3rs0hh269y9h8e.png" alt="Capturing Smart Contract Development" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;You will need the following tools installed to build along with me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;li&gt;Yarn&lt;/li&gt;
&lt;li&gt;Git Bash&lt;/li&gt;
&lt;li&gt;MetaMask&lt;/li&gt;
&lt;li&gt;Next.js&lt;/li&gt;
&lt;li&gt;Solidity&lt;/li&gt;
&lt;li&gt;Redux Toolkit&lt;/li&gt;
&lt;li&gt;Tailwind CSS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To set up MetaMask for this tutorial, please watch the instructional video below:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/qV1mbFOtkxo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Once you have successfully completed the setup, you are eligible to receive a free copy of our book. To claim your book, &lt;a href="https://forms.gle/uGtm3ZcEHb5pqd3YA" rel="noopener noreferrer"&gt;please fill out the form to submit your proof-of-work&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Watch the following &lt;a href="https://www.youtube.com/playlist?list=PLUDcVqFK2t-C36KaTMzV3y1wu8Hf-qyAI" rel="noopener noreferrer"&gt;&lt;strong&gt;instructional videos&lt;/strong&gt;&lt;/a&gt; to receive up to 3-months of free premium courses on Dapp Mentors Academy, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dappmentors.org/courses/details/fullstack-nft-minting-course" rel="noopener noreferrer"&gt;Fullstack NFT Minting Course&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dappmentors.org/courses/details/fullstack-nft-marketplace-course" rel="noopener noreferrer"&gt;Fullstack NFT Marketplace Course&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dappmentors.org/courses/details/fullstack-blockchain-101-course" rel="noopener noreferrer"&gt;Fullstack Blockchain Course&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Continue your Bitfinity journey by learning how to build easy Play-to-Earn dApps. Discover the potential of blockchain gaming in the next module. &lt;a href="https://bitfinity.network/" rel="noopener noreferrer"&gt;&lt;strong&gt;Dive deeper into Bitfinity and deploy your smart contracts to the network.&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With that said, let’s jump into the tutorial and set up our project.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;We'll start by cloning a prepared frontend repository and setting up the environment variables. Run the following commands:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/Daltonic/dappBnbX
cd dappBnbX
yarn install
git checkout no_redux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Next, create a &lt;code&gt;.env&lt;/code&gt; file at the root of the project and include the following keys:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NEXT_PUBLIC_RPC_URL=http://127.0.0.1:8545
NEXT_PUBLIC_ALCHEMY_ID=&amp;lt;YOUR_ALCHEMY_PROJECT_ID&amp;gt;
NEXT_PUBLIC_PROJECT_ID=&amp;lt;WALLET_CONNECT_PROJECT_ID&amp;gt;
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=somereallysecretsecret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Replace &lt;code&gt;&amp;lt;YOUR_ALCHEMY_PROJECT_ID&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;WALLET_CONNECT_PROJECT_ID&amp;gt;&lt;/code&gt; with your respective project IDs. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;YOUR_ALCHEMY_PROJECT_ID&lt;/code&gt;: &lt;a href="https://dashboard.alchemy.com/" rel="noopener noreferrer"&gt;Get Key Here&lt;/a&gt; &lt;br&gt;
&lt;code&gt;WALLET_CONNECT_PROJECT_ID&lt;/code&gt;: &lt;a href="https://cloud.walletconnect.com/sign-in" rel="noopener noreferrer"&gt;Get Key Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, run &lt;code&gt;yarn dev&lt;/code&gt; to start the project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpiw572hbgalzb5kthmbt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpiw572hbgalzb5kthmbt.png" alt="Dummy Data" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our frontend is ready for smart contract integration, but we need to implement Redux to enable shared data space.&lt;/p&gt;
&lt;h2&gt;
  
  
  Building the Redux Store
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgh2vkiqoomgmpwakcvcg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgh2vkiqoomgmpwakcvcg.png" alt="Store Structure" width="800" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above image represents the structure of our Redux store, it will be simple since we are not creating some overly complex project.&lt;/p&gt;

&lt;p&gt;We'll set up Redux to manage our application's global state. Follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;store&lt;/code&gt; folder at the project root.&lt;/li&gt;
&lt;li&gt;Inside &lt;code&gt;store&lt;/code&gt;, create two folders: &lt;code&gt;actions&lt;/code&gt; and &lt;code&gt;states&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Inside &lt;code&gt;states&lt;/code&gt;, create a &lt;code&gt;globalStates.js&lt;/code&gt; file.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Inside &lt;code&gt;actions&lt;/code&gt;, create a &lt;code&gt;globalActions.js&lt;/code&gt; file.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;globalSlices.js&lt;/code&gt; file inside the &lt;code&gt;store&lt;/code&gt; folder.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Create an &lt;code&gt;index.js&lt;/code&gt; file inside the &lt;code&gt;store&lt;/code&gt; folder.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Update the &lt;code&gt;pages/_app.jsx&lt;/code&gt; file with the Redux provider.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We have implemented Redux toolkit in our application and plan to revisit its usage when integrating the backend with the frontend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Smart Contract Development
&lt;/h2&gt;

&lt;p&gt;Next, we'll develop the smart contract for our platform:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;contracts&lt;/code&gt; folder at the project root.&lt;/li&gt;
&lt;li&gt;Inside &lt;code&gt;contracts&lt;/code&gt;, create a &lt;code&gt;DappBnb.sol&lt;/code&gt; file and add the contract code below.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;DappBnb&lt;/code&gt; contract represents a decentralized house rental platform where users can list apartments for rent, book available apartments, and leave reviews. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's go through each part of the contract:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Contract Setup and Libraries:&lt;/strong&gt; The contract imports &lt;code&gt;Ownable&lt;/code&gt;, &lt;code&gt;Counters&lt;/code&gt;, and &lt;code&gt;ReentrancyGuard&lt;/code&gt; from the OpenZeppelin library. &lt;code&gt;Ownable&lt;/code&gt; provides basic authorization control functions, &lt;code&gt;Counters&lt;/code&gt; is used for counting variables, and &lt;code&gt;ReentrancyGuard&lt;/code&gt; helps prevent re-entrancy attacks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Struct Definitions:&lt;/strong&gt; The contract defines three structs: &lt;code&gt;ApartmentStruct&lt;/code&gt;, &lt;code&gt;BookingStruct&lt;/code&gt;, and &lt;code&gt;ReviewStruct&lt;/code&gt;. These define the data structures for apartments, bookings, and reviews respectively.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;State Variables:&lt;/strong&gt; The contract declares several state variables, including security fees, tax percentages, and mappings to keep track of apartments, bookings, reviews, and other related data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Constructor:&lt;/strong&gt; The constructor function initializes the &lt;code&gt;taxPercent&lt;/code&gt; and &lt;code&gt;securityFee&lt;/code&gt; state variables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Apartment Functions:&lt;/strong&gt; Functions like &lt;code&gt;createApartment&lt;/code&gt;, &lt;code&gt;updateApartment&lt;/code&gt;, &lt;code&gt;deleteApartment&lt;/code&gt;, &lt;code&gt;getApartments&lt;/code&gt;, and &lt;code&gt;getApartment&lt;/code&gt; are used to manage apartment listings on the platform.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Booking Functions:&lt;/strong&gt; Functions like &lt;code&gt;bookApartment&lt;/code&gt;, &lt;code&gt;checkInApartment&lt;/code&gt;, &lt;code&gt;claimFunds&lt;/code&gt;, &lt;code&gt;refundBooking&lt;/code&gt;, &lt;code&gt;getUnavailableDates&lt;/code&gt;, &lt;code&gt;getBookings&lt;/code&gt;, &lt;code&gt;getQualifiedReviewers&lt;/code&gt;, and &lt;code&gt;getBooking&lt;/code&gt; are used to manage the booking process and interactions between tenants and apartment owners.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Review Functions:&lt;/strong&gt; The &lt;code&gt;addReview&lt;/code&gt; and &lt;code&gt;getReviews&lt;/code&gt; functions manage the review process, allowing tenants to leave reviews for apartments they've booked.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Utility Functions:&lt;/strong&gt; The &lt;code&gt;payTo&lt;/code&gt; and &lt;code&gt;currentTime&lt;/code&gt; functions are utility functions used in multiple other functions. &lt;code&gt;payTo&lt;/code&gt; is used to transfer funds between addresses, and &lt;code&gt;currentTime&lt;/code&gt; returns the current block timestamp.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Contract Deployment and Seeding
&lt;/h2&gt;

&lt;p&gt;Now, let's deploy our smart contract and populate it with some dummy data:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;scripts&lt;/code&gt; folder at the project root.&lt;/li&gt;
&lt;li&gt;Inside &lt;code&gt;scripts&lt;/code&gt;, create a &lt;code&gt;deploy.js&lt;/code&gt; and a &lt;code&gt;seed.js&lt;/code&gt; file and add the following codes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Deploy Script&lt;/strong&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Seed Script&lt;/strong&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Run the following commands to deploy the contract and seed it with data:&lt;/p&gt;

&lt;p&gt;yarn hardhat node # Run in terminal 1&lt;br&gt;
yarn hardhat run scripts/deploy.js # Run in terminal 2&lt;br&gt;
yarn hardhat run scripts/seed.js # Run in terminal 2&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you did that correctly, you should see a similar output like the one below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fjsb0x1bcugf2sqnjdx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fjsb0x1bcugf2sqnjdx.png" alt="Deployment" width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point we can start the integration of our smart contract to our frontend.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Ubom39y5jX8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Frontend Integration
&lt;/h2&gt;

&lt;p&gt;First, create a &lt;code&gt;services&lt;/code&gt; folder at the project root, and inside it, create a &lt;code&gt;blockchain.jsx&lt;/code&gt; file. This file will contain functions to interact with our smart contract.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The above script is a service that interacts with a smart contract deployed on the chain. In a joint effort with EthersJs, it provides functions to read and write data on the blockchain via the contract's methods. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here's a breakdown of the functions:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getEthereumContracts:&lt;/strong&gt; This function establishes a connection to the Ethereum network either through a browser provider (if available) or via a JSON-RPC endpoint. It then creates an instance of the smart contract using its ABI and address. If a user is connected via their wallet, the contract instance is linked to the user's account. Otherwise, a random account is generated and linked to the contract.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getApartments, getApartment:&lt;/strong&gt; These functions fetch all apartments and a specific apartment respectively from the smart contract.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getBookings:&lt;/strong&gt; Fetches all bookings for a specific apartment from the smart contract.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getQualifiedReviewers:&lt;/strong&gt; Fetches all addresses that are qualified to leave reviews for a specific apartment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getReviews:&lt;/strong&gt; Fetches all reviews for a specific apartment from the smart contract.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getBookedDates:&lt;/strong&gt; Fetches all dates that are booked for a specific apartment from the smart contract.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;getSecurityFee:&lt;/strong&gt; Fetches the security fee from the smart contract.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;createApartment, updateApartment, deleteApartment:&lt;/strong&gt; These functions allow a user to create, update, and delete apartments respectively. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;bookApartment:&lt;/strong&gt; This function allows a user to book an apartment for specific dates. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;checkInApartment:&lt;/strong&gt; This function allows a user to check into an apartment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;refundBooking:&lt;/strong&gt; This function allows a user to get a refund for a booking. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;addReview:&lt;/strong&gt; This function allows a user to add a review for an apartment.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Update the &lt;code&gt;provider.jsx&lt;/code&gt; file inside &lt;code&gt;services&lt;/code&gt; to include the &lt;code&gt;bitfinity&lt;/code&gt; network using the following codes.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Page Interacting with Smart Contract
&lt;/h2&gt;

&lt;p&gt;Next, we'll link the functions in the blockchain service to their respective interfaces in the frontend:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No 1:  Displaying Available Apartments&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/index.jsx&lt;/code&gt; to get data from the &lt;code&gt;getApartments()&lt;/code&gt; function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 2: Displaying Single Apartment&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/room/[roomId].jsx&lt;/code&gt; to use the &lt;code&gt;getServerSideProps()&lt;/code&gt;, &lt;code&gt;getApartment()&lt;/code&gt;, &lt;code&gt;getBookedDates()&lt;/code&gt; and the other functions to retrieve apartment and booking details by the room’s Id.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 3: Creating New Apartments&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/room/add.jsx&lt;/code&gt; to use the &lt;code&gt;createApartment()&lt;/code&gt; function for form submission.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 4: Editing Existing Apartments&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/room/edit/[roomId].jsx&lt;/code&gt; to use the &lt;code&gt;getApartment()&lt;/code&gt; function to retrieve apartment by Id and populate the form fields.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 5:  Displaying All Bookings&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;pages/bookings/roomId.jsx&lt;/code&gt; to get data from the &lt;code&gt;getApartment()&lt;/code&gt; and &lt;code&gt;getBookings()&lt;/code&gt; functions.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Components with Smart Contract
&lt;/h2&gt;

&lt;p&gt;Like we did with the pages above, let’s Update the following components to interact with the smart contract:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No 1: Handling Apartment Deletion&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;components/Actions.jsx&lt;/code&gt; file to use the &lt;code&gt;handleDelete()&lt;/code&gt; function to call the &lt;code&gt;deleteApartment()&lt;/code&gt; functions.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 2: Adding Reviews to Apartment&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;components/AddReview.jsx&lt;/code&gt; modal to use the &lt;code&gt;handleSubmit()&lt;/code&gt; function to call the &lt;code&gt;addReview()&lt;/code&gt; function. &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Observe how Redux was used to open and close the review modal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No 3: Adding Reviews to Apartment&lt;/strong&gt;&lt;br&gt;
Update &lt;code&gt;components/Booking.jsx&lt;/code&gt; file to use the &lt;code&gt;handleCheckIn()&lt;/code&gt; and &lt;code&gt;handleRefund()&lt;/code&gt; functions. &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;No 4: Adding Reviews to Apartment&lt;/strong&gt;&lt;br&gt;
Lastly, update &lt;code&gt;components/Calendar.jsx&lt;/code&gt; file to use the &lt;code&gt;handleSubmit()&lt;/code&gt; function to call the &lt;code&gt;bookApartment()&lt;/code&gt; function. &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Also notice that we are using Redux to retrieve the security fee which is necessary to calculate the cost of booking an apartment.&lt;/p&gt;

&lt;p&gt;The project is now complete as all components and pages are connected to the smart contract through the implementation of these updates.&lt;/p&gt;

&lt;p&gt;If your Next.js server was offline, you can bring it back up by executing the command &lt;code&gt;yarn dev&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For further learning, we recommends watch the full video of this build on our &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube channel&lt;/strong&gt;&lt;/a&gt; and &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;&lt;strong&gt;visiting our website for additional resources&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Qoa6z6c_wYQ"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;In this tutorial, we've built a Decentralized House Rental Platform using Next.js, Redux, and Solidity. We set up the development environment, built the Redux store, and deployed the smart contract to the blockchain. By integrating the smart contract with the frontend, we created a seamless user experience. &lt;/p&gt;

&lt;p&gt;Throughout the tutorial, you gained valuable skills in building Web3 applications, crafting smart contracts, and incorporating static type checking. You also learned how to use Redux for shared data space and interact with smart contracts from the frontend. &lt;/p&gt;

&lt;p&gt;Now, you're ready to create your own Decentralized House Rental Platform. Happy coding and unleash your innovation in the world of Web3!&lt;/p&gt;

&lt;h2&gt;
  
  
  About Author
&lt;/h2&gt;

&lt;p&gt;I am a web3 developer and the founder of &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Dapp Mentors&lt;/a&gt;, a company that helps businesses and individuals build and launch decentralized applications. I have over 7 years of experience in the software industry, and I am passionate about using blockchain technology to create new and innovative applications. I run a &lt;a href="https://www.youtube.com/@dappmentors?sub_confirmation=1" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube channel called Dapp Mentors&lt;/strong&gt;&lt;/a&gt; where I share tutorials and tips on web3 development, and I regularly post articles online about the latest trends in the blockchain space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stay connected with us, join communities on&lt;/strong&gt;&lt;br&gt;
Discord: &lt;a href="https://discord.gg/PgFDUVT6n9" rel="noopener noreferrer"&gt;Join&lt;/a&gt;&lt;br&gt;
X-Twitter: &lt;a href="https://twitter.com/iDaltonic" rel="noopener noreferrer"&gt;Follow&lt;/a&gt;&lt;br&gt;
LinkedIn: &lt;a href="https://www.linkedin.com/company/dapp-mentors" rel="noopener noreferrer"&gt;Connect&lt;/a&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/Daltonic" rel="noopener noreferrer"&gt;Explore&lt;/a&gt;&lt;br&gt;
Website: &lt;a href="https://dappmentors.org/" rel="noopener noreferrer"&gt;Visit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>web3</category>
      <category>nextjs</category>
      <category>solidity</category>
      <category>dapp</category>
    </item>
  </channel>
</rss>
