<?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: amionweb</title>
    <description>The latest articles on DEV Community by amionweb (@amionweb).</description>
    <link>https://dev.to/amionweb</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%2F1452510%2F7c7a3a56-fe0f-4731-a8e9-728dab67a6ea.png</url>
      <title>DEV Community: amionweb</title>
      <link>https://dev.to/amionweb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amionweb"/>
    <language>en</language>
    <item>
      <title>RoboFire: Cloud Clash Game Challenge Submission: Alibaba Cloud Web Game</title>
      <dc:creator>amionweb</dc:creator>
      <pubDate>Sun, 27 Apr 2025 10:35:47 +0000</pubDate>
      <link>https://dev.to/amionweb/robofire-cloud-clash-game-challenge-submission-alibaba-cloud-web-game-o0j</link>
      <guid>https://dev.to/amionweb/robofire-cloud-clash-game-challenge-submission-alibaba-cloud-web-game-o0j</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://int.alibabacloud.com/m/1000402443/" rel="noopener noreferrer"&gt;Alibaba Cloud&lt;/a&gt; Challenge: &lt;a href="https://dev.to/challenges/alibaba"&gt;Build a Web Game&lt;/a&gt;.&lt;/em&gt;*&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;An exciting arcade-style game where you control a robot shooting down clouds and collecting coins while avoiding dangerous obstacles!&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Live url:&lt;/strong&gt; &lt;a href="https://robo-fire.vercel.app/" rel="noopener noreferrer"&gt;https://robo-fire.vercel.app/&lt;/a&gt;&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/amionweb" rel="noopener noreferrer"&gt;
        amionweb
      &lt;/a&gt; / &lt;a href="https://github.com/amionweb/robo-fire" rel="noopener noreferrer"&gt;
        robo-fire
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;RoboFire: Cloud Clash 🤖☁️&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;An exciting arcade-style game where you control a robot shooting down clouds and collecting coins while avoiding dangerous obstacles!&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;🎮 Play Now&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="https://robo-fire.vercel.app/" rel="nofollow noopener noreferrer"&gt;Play RoboFire: Cloud Clash&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;✨ Features&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;🎯 Intuitive controls with keyboard support&lt;/li&gt;
&lt;li&gt;🌟 Beautiful visual effects and animations&lt;/li&gt;
&lt;li&gt;🎨 Smooth gameplay mechanics&lt;/li&gt;
&lt;li&gt;📈 Progressive difficulty system&lt;/li&gt;
&lt;li&gt;🏆 High score tracking&lt;/li&gt;
&lt;li&gt;🎵 Engaging sound effects&lt;/li&gt;
&lt;li&gt;📱 Responsive design&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;🕹️ How to Play&lt;/h2&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;Use &lt;strong&gt;Arrow keys&lt;/strong&gt; or &lt;strong&gt;WASD&lt;/strong&gt; to move your robot&lt;/li&gt;
&lt;li&gt;Press &lt;strong&gt;Spacebar&lt;/strong&gt; to shoot at clouds&lt;/li&gt;
&lt;li&gt;Collect falling coins to score points&lt;/li&gt;
&lt;li&gt;Avoid obstacles (lightning bolts and asteroids)&lt;/li&gt;
&lt;li&gt;Reach level 10 to win!&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;🚀 Getting Started&lt;/h2&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Clone the repository&lt;/span&gt;
git clone https://github.com/amionweb/robo-fire

&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Navigate to the project directory&lt;/span&gt;
&lt;span class="pl-c1"&gt;cd&lt;/span&gt; robofire-cloud-clash

&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Install dependencies&lt;/span&gt;
npm install

&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Start the development server&lt;/span&gt;
npm run dev&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;🛠️ Built With&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;React&lt;/li&gt;
&lt;li&gt;TypeScript&lt;/li&gt;
&lt;li&gt;HTML5 Canvas&lt;/li&gt;
&lt;li&gt;TailwindCSS&lt;/li&gt;
&lt;li&gt;Vite&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;🎯 Game Mechanics&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Clouds&lt;/strong&gt;: Shoot them to create collectible coins&lt;/li&gt;
&lt;li&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/amionweb/robo-fire" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&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%2Fnob7age1x6e65yqfzdlq.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%2Fnob7age1x6e65yqfzdlq.png" alt=" "&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%2Fjkcgskj9lgrval3psmc7.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%2Fjkcgskj9lgrval3psmc7.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ☁️ Alibaba Cloud Services Implementation
&lt;/h2&gt;

&lt;p&gt;For RoboFire: Cloud Clash, I used &lt;strong&gt;Alibaba Cloud Object Storage Service (OSS)&lt;/strong&gt; to &lt;strong&gt;host and serve&lt;/strong&gt; the static game files, and configured a &lt;strong&gt;custom domain&lt;/strong&gt; for a professional, fast-loading experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Services Used:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Object Storage Service (OSS)&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; OSS provides a highly reliable, scalable, and cost-effective way to store static web assets like HTML, CSS, JavaScript, and images.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How Integrated:&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Built the game locally with &lt;code&gt;npm run build&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Uploaded the build folder contents directly to an OSS bucket.&lt;/li&gt;
&lt;li&gt;Configured the bucket for &lt;strong&gt;static website hosting&lt;/strong&gt; (setting the index document to &lt;code&gt;index.html&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Experience:&lt;/strong&gt;
OSS made it extremely easy to deploy updates — I just re-upload the latest build files. The performance was excellent with low latency globally.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Domain Management + Custom Domain Binding&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why:&lt;/strong&gt; Custom domains make the game more shareable and professional.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How Integrated:&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Purchased or linked an existing domain via Alibaba Cloud Domains.&lt;/li&gt;
&lt;li&gt;Mapped the domain to my OSS bucket via a CNAME record.&lt;/li&gt;
&lt;li&gt;Configured HTTPS using Alibaba Cloud SSL certificates for secure access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Experience:&lt;/strong&gt;
Domain setup was straightforward following Alibaba Cloud's documentation. Enabling HTTPS ensured that game assets loaded securely without browser warnings.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Benefits:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Fast content delivery worldwide&lt;/li&gt;
&lt;li&gt;Very low maintenance and update cost&lt;/li&gt;
&lt;li&gt;Scalable without worrying about backend servers&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Challenges:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The initial learning curve with setting correct bucket permissions (public read) for the static website.&lt;/li&gt;
&lt;li&gt;Slight delay (~10–15 mins) when applying custom domain settings and SSL.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🎯 Game Development Highlights
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Simple Yet Addictive Gameplay:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;I designed RoboFire: Cloud Clash to have a fast gameplay loop — move, shoot, collect, avoid — making it highly engaging even with minimal mechanics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Progressive Difficulty
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;One of the coolest features is the dynamic level system. As players collect coins, the enemy cloud speed increases, making higher levels genuinely challenging without introducing complex new elements.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Clean Responsive Canvas Integration
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Using &lt;strong&gt;HTML5 Canvas&lt;/strong&gt; inside a &lt;strong&gt;React&lt;/strong&gt; environment with &lt;strong&gt;Vite&lt;/strong&gt; made rendering super fast and allowed the game to adapt nicely to different screen sizes (desktop, tablet, mobile).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Retro-Futuristic Visuals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;I’m especially proud of the polished visual design — a clean, modern robot combined with nostalgic arcade-style effects like glowing coins and cloud explosions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Optimized Performance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Despite animations and firing mechanics, the game remains lightweight (~a few MBs), fast-loading, and smooth at 60fps even on lower-end devices.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>alibabachallenge</category>
      <category>devchallenge</category>
      <category>gamedev</category>
      <category>webdev</category>
    </item>
    <item>
      <title>From Components to Creativity: Building a Portfolio with KendoReact</title>
      <dc:creator>amionweb</dc:creator>
      <pubDate>Mon, 24 Mar 2025 06:45:29 +0000</pubDate>
      <link>https://dev.to/amionweb/from-components-to-creativity-building-a-portfolio-with-kendoreact-343n</link>
      <guid>https://dev.to/amionweb/from-components-to-creativity-building-a-portfolio-with-kendoreact-343n</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/kendoreact"&gt;KendoReact Free Components Challenge&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What I Built
&lt;/h3&gt;

&lt;p&gt;I built a personal portfolio website using React and KendoReact components. The portfolio showcases my skills, experience, projects, and testimonials from clients. The website is designed to be responsive, with a clean and modern UI that adapts to both light and dark themes. The portfolio includes several sections such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Hero Section&lt;/em&gt;: A visually appealing introduction with a 3D animated background and a call-to-action to download my resume or get in touch.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;About Section&lt;/em&gt;: A brief introduction about myself, my skills, and what I specialize in.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Experience Section&lt;/em&gt;: A timeline of my professional experience, highlighting key roles and responsibilities.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Projects Section&lt;/em&gt;: A showcase of my featured projects, including technologies used and completion status.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Technologies Section&lt;/em&gt;: A detailed breakdown of my technical skills, categorized by frontend, backend, and DevOps.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Testimonials Section&lt;/em&gt;: Client testimonials with ratings, displayed in a grid layout for desktop and a carousel for mobile.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Contact Section&lt;/em&gt;: A form for visitors to get in touch with me, along with my contact information and social media links.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The portfolio is built with a focus on user experience, leveraging animations and transitions to create a smooth and engaging browsing experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Demo
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://kendo-portfolio-lemon.vercel.app/" rel="noopener noreferrer"&gt;https://kendo-portfolio-lemon.vercel.app/&lt;/a&gt;&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/amionweb" rel="noopener noreferrer"&gt;
        amionweb
      &lt;/a&gt; / &lt;a href="https://github.com/amionweb/kendo-portfolio" rel="noopener noreferrer"&gt;
        kendo-portfolio
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;h3&gt;
  
  
  KendoReact Experience
&lt;/h3&gt;

&lt;p&gt;I leveraged KendoReact's free components extensively throughout the portfolio to create a polished and professional UI. Here are some of the key components I used:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Card Components&lt;/em&gt;: Used in multiple sections (About, Experience, Projects, Testimonials) to display content in a structured and visually appealing way.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;TileLayout&lt;/em&gt;: Used in the About section to display my skills in a grid layout with staggered animations.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Fade Animation&lt;/em&gt;: Applied across various sections to create smooth fade-in animations as the user scrolls through the page.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Button Components&lt;/em&gt;: Used for call-to-action buttons, theme toggling, and navigation.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;ProgressBar&lt;/em&gt;: Used in the Projects and Technologies sections to visually represent skill levels and project completion status.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Chip and ChipList&lt;/em&gt;: Used in the Projects section to display the technologies used in each project.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Avatar&lt;/em&gt;: Used in the Testimonials section to display client images.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Input and Label&lt;/em&gt;: Used in the Contact section for the form fields.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Drawer&lt;/em&gt;: Used in the mobile navigation menu to provide a smooth and responsive user experience.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;AppBar&lt;/em&gt;: Used for the navigation bar, which is fixed at the top and adapts to the scroll position.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By using these KendoReact components, I was able to focus more on the overall design and functionality of the portfolio, rather than spending time building UI components from scratch. The components provided by KendoReact are highly customizable and integrate seamlessly with React, making the development process efficient and enjoyable.&lt;/p&gt;

&lt;h3&gt;
  
  
  AIm to Impress
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Delightfully Designed
&lt;/h3&gt;

</description>
      <category>devchallenge</category>
      <category>kendoreactchallenge</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Kendo React Challenge Submission</title>
      <dc:creator>amionweb</dc:creator>
      <pubDate>Mon, 24 Mar 2025 06:26:56 +0000</pubDate>
      <link>https://dev.to/amionweb/kendo-react-challenge-submission-3l84</link>
      <guid>https://dev.to/amionweb/kendo-react-challenge-submission-3l84</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/kendoreact"&gt;KendoReact Free Components Challenge&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Demo
&lt;/h3&gt;

&lt;h2&gt;
  
  
  KendoReact Experience
&lt;/h2&gt;

&lt;h3&gt;
  
  
  AIm to Impress
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Delightfully Designed
&lt;/h3&gt;

</description>
      <category>devchallenge</category>
      <category>kendoreactchallenge</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Stellar contract CRUD Tutorial: Smart Contract Challenge</title>
      <dc:creator>amionweb</dc:creator>
      <pubDate>Mon, 19 Aug 2024 06:55:47 +0000</pubDate>
      <link>https://dev.to/amionweb/stellar-contract-crud-tutorial-smart-contract-challenge-1n74</link>
      <guid>https://dev.to/amionweb/stellar-contract-crud-tutorial-smart-contract-challenge-1n74</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/stellar"&gt;Build Better on Stellar: Smart Contract Challenge &lt;/a&gt;: Create a Tutorial&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Your Tutorial
&lt;/h2&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/amionweb" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F1452510%2F7c7a3a56-fe0f-4731-a8e9-728dab67a6ea.png" alt="amionweb"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/amionweb/stellar-contract-crud-tutorial-a-step-by-step-guide-from-zero-to-hero-536a" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Stellar contract CRUD Tutorial A Step-by-Step Guide from Zero to Hero&lt;/h2&gt;
      &lt;h3&gt;amionweb ・ Aug 19 '24&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#stellarchallenge&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;Here’s a structured submission for the "Build Better on Stellar: Smart Contract Challenge":&lt;/p&gt;




&lt;h2&gt;
  
  
  What I Created
&lt;/h2&gt;

&lt;p&gt;For the "Build Better on Stellar: Smart Contract Challenge," I developed a comprehensive smart contract for managing products on the Stellar blockchain. This contract includes CRUD (Create, Read, Update, Delete) operations, allowing users to manage product listings effectively. The functionalities include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Create a Product:&lt;/strong&gt; Adds a new product to the system with details like name, description, and price.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Get a Product by ID:&lt;/strong&gt; Retrieves a product's details using its unique ID.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Update a Product:&lt;/strong&gt; Updates the product's details, including its name, description, and price.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delete a Product:&lt;/strong&gt; Marks a product as inactive without removing it from storage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permanently Delete a Product:&lt;/strong&gt; Completely removes a product from storage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delete All Products:&lt;/strong&gt; Clears all products from the system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This contract enhances the Stellar developer experience by providing a practical example of managing data through smart contracts. Developers can utilize this contract as a blueprint for their own projects, easily adapting it to different use cases by modifying the product data structure or extending functionalities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Journey
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Research and Content Creation
&lt;/h3&gt;

&lt;p&gt;My journey began with researching the Stellar smart contract capabilities and the Soroban SDK, which is used to build smart contracts on Stellar. I studied existing examples and documentation to understand best practices and the nuances of developing smart contracts in Rust.&lt;/p&gt;

&lt;h3&gt;
  
  
  Motivation
&lt;/h3&gt;

&lt;p&gt;The motivation behind this submission was to create a flexible and practical example of a smart contract that could be immediately useful to other developers. The goal was to provide a straightforward implementation of CRUD operations, which are fundamental for many applications. By using this example, developers can get a head start on building and deploying their own smart contracts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Learning and Experience
&lt;/h3&gt;

&lt;p&gt;Throughout this process, I gained a deeper understanding of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Smart Contract Development:&lt;/strong&gt; From writing and deploying smart contracts to handling data persistence on the Stellar blockchain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stellar Ecosystem:&lt;/strong&gt; How to interact with the Stellar network using Soroban SDK and the specific requirements for smart contracts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rust Programming:&lt;/strong&gt; Leveraging Rust for building secure and efficient smart contracts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I am particularly proud of creating a well-documented and functional contract that simplifies the complexities of smart contract development on Stellar. It is designed to be a practical resource for beginners and experienced developers alike.&lt;/p&gt;

&lt;h3&gt;
  
  
  Future Goals
&lt;/h3&gt;

&lt;p&gt;Moving forward, I plan to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Extend Functionality:&lt;/strong&gt; Add features such as user authentication and role-based access control to the contract.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improve Documentation:&lt;/strong&gt; Create more detailed tutorials and examples to help developers integrate and customize smart contracts in their projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explore Other Use Cases:&lt;/strong&gt; Develop smart contracts for different applications, such as financial transactions or decentralized voting systems, to broaden the scope of practical implementations on Stellar.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This submission represents a foundational step in the journey of integrating smart contracts into real-world applications on the Stellar blockchain. It is designed to be both educational and practical, providing a valuable tool for developers looking to build on Stellar.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>stellarchallenge</category>
      <category>blockchain</category>
      <category>web3</category>
    </item>
    <item>
      <title>Stellar contract CRUD Tutorial A Step-by-Step Guide from Zero to Hero</title>
      <dc:creator>amionweb</dc:creator>
      <pubDate>Mon, 19 Aug 2024 06:55:24 +0000</pubDate>
      <link>https://dev.to/amionweb/stellar-contract-crud-tutorial-a-step-by-step-guide-from-zero-to-hero-536a</link>
      <guid>https://dev.to/amionweb/stellar-contract-crud-tutorial-a-step-by-step-guide-from-zero-to-hero-536a</guid>
      <description>&lt;p&gt;In this tutorial, we'll guide you through creating a Stellar smart contract from scratch. You'll learn how to implement basic CRUD (Create, Read, Update, Delete) operations for managing products in a decentralized application (dApp). By the end of this tutorial, you'll be able to add, update, delete, view, and get all products using a Stellar smart contract.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before we dive into the code, make sure you have the following:&lt;/p&gt;

&lt;h2&gt;
  
  
  Set Up Environment / Project Installation Guide
&lt;/h2&gt;

&lt;h3&gt;
  
  
  A) Environment Setup:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Install Rust, using command:&lt;br&gt;
&lt;code&gt;curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;nstall the Soroban CLI using below mentioned command. For more info visit =&amp;gt; &lt;a href="https://developers.stellar.org/docs/smart-contracts" rel="noopener noreferrer"&gt;Soroban docs&lt;/a&gt;&lt;br&gt;
&lt;code&gt;cargo install --locked soroban-cli&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install &lt;a href="https://nodejs.org/en" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get the &lt;a href="https://www.freighter.app/" rel="noopener noreferrer"&gt;Freighter Wallet&lt;/a&gt; extension for you browser.&lt;br&gt;
Once enabled, then got to the network section and connect your wallet to the testnet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install wasm32-unknown-unknown package using command:&lt;br&gt;
&lt;code&gt;rustup target add wasm32-unknown-unknown&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To configure your CLI to interact with Testnet, run the following command:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;soroban network add \
  --global testnet \
  --rpc-url https://soroban-testnet.stellar.org:443 \
  --network-passphrase "Test SDF Network ; September 2015"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 1: Setting Up the Project
&lt;/h3&gt;

&lt;p&gt;First, create a new Rust project by running the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;stellar contract init product-crud
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Navigate to the project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;product-crud
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These dependencies allow us to interact with Stellar's Soroban platform.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Defining the Product Struct
&lt;/h3&gt;

&lt;p&gt;In your &lt;code&gt;lib.rs&lt;/code&gt; file, start by defining the &lt;code&gt;Product&lt;/code&gt; struct. This struct will hold the details of each product.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nd"&gt;#![no_std]&lt;/span&gt; &lt;span class="c1"&gt;// We don't use the Rust standard library in smart contracts&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;soroban_sdk&lt;/span&gt;&lt;span class="p"&gt;::{&lt;/span&gt;&lt;span class="n"&gt;contracttype&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Struct to represent a product in our dApp&lt;/span&gt;
&lt;span class="nd"&gt;#[contracttype]&lt;/span&gt;
&lt;span class="nd"&gt;#[derive(Clone)]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;              &lt;span class="c1"&gt;// Unique ID for the product&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="c1"&gt;// Name of the product&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;// Description of the product&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;           &lt;span class="c1"&gt;// Price of the product&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;Product&lt;/code&gt; struct is defined with fields such as &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;description&lt;/code&gt;, and &lt;code&gt;price&lt;/code&gt;. This struct will store information about each product.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 4: Setting Up the Contract
&lt;/h3&gt;

&lt;p&gt;Next, define the main contract structure and the CRUD operations. Here's how you can start:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;soroban_sdk&lt;/span&gt;&lt;span class="p"&gt;::{&lt;/span&gt;&lt;span class="n"&gt;contract&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;contractimpl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;symbol_short&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Define a contract type called ProductContract&lt;/span&gt;
&lt;span class="nd"&gt;#[contract]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;ProductContract&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Enum for referencing product storage&lt;/span&gt;
&lt;span class="nd"&gt;#[contracttype]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="n"&gt;Productbook&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;u64&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Symbol to track the total count of products&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;COUNT_PRODUCT&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Symbol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nd"&gt;symbol_short!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"C_PROD"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;ProductContract&lt;/code&gt; struct is defined as the main contract.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Productbook&lt;/code&gt; is an enum used to store and retrieve products by their ID.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;COUNT_PRODUCT&lt;/code&gt; is a symbol used to track the number of products stored.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 5: Implementing the Create Operation
&lt;/h3&gt;

&lt;p&gt;Now, let's implement the function to create a new product.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nd"&gt;#[contractimpl]&lt;/span&gt;
&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="n"&gt;ProductContract&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;create_product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;u64&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;count_product&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u64&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="nf"&gt;.storage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.instance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;COUNT_PRODUCT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="nf"&gt;.unwrap_or&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;count_product&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;new_product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;count_product&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;

        &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="nf"&gt;.storage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="nf"&gt;.instance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="nf"&gt;.set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nn"&gt;Productbook&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_product&lt;/span&gt;&lt;span class="py"&gt;.id&lt;/span&gt;&lt;span class="nf"&gt;.clone&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;new_product&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="nf"&gt;.storage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.instance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;COUNT_PRODUCT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;count_product&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;log&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Product Created with ID: {}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;new_product&lt;/span&gt;&lt;span class="py"&gt;.id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="n"&gt;new_product&lt;/span&gt;&lt;span class="py"&gt;.id&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;create_product&lt;/code&gt; function increments the &lt;code&gt;count_product&lt;/code&gt; by 1 and creates a new product with the provided details.&lt;/li&gt;
&lt;li&gt;The product is then stored in the contract's storage, and the ID of the newly created product is returned.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 6: Implementing the Read Operation
&lt;/h3&gt;

&lt;p&gt;Let's add a function to retrieve a product by its ID.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="n"&gt;ProductContract&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;get_product_by_id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;Productbook&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="nf"&gt;.storage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.instance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="nf"&gt;.unwrap_or&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from_str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Not Found"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from_str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Not Found"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;get_product_by_id&lt;/code&gt; function retrieves a product from storage by its ID. If the product is not found, it returns a default &lt;code&gt;Product&lt;/code&gt; with "Not Found" values.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 7: Implementing the Update Operation
&lt;/h3&gt;

&lt;p&gt;Now, add a function to update the details of an existing product.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="n"&gt;ProductContract&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;update_product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;new_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;new_description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;new_price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;u64&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;Productbook&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;Self&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get_product_by_id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="nf"&gt;.clone&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nf"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new_name&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="py"&gt;.name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nf"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new_description&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="py"&gt;.description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nf"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new_price&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="py"&gt;.price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="nf"&gt;.storage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.instance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;log&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Product with ID: {} has been updated."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;update_product&lt;/code&gt; function allows updating the product's name, description, and price. If new values are provided, they replace the existing ones.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 8: Implementing the Delete Operation
&lt;/h3&gt;

&lt;p&gt;Finally, let's implement a function to delete a product by its ID.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="n"&gt;ProductContract&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;delete_product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;Productbook&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="nf"&gt;.storage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.instance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="nf"&gt;.storage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.instance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

            &lt;span class="k"&gt;log&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Product with ID: {} has been deleted."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;log&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Product with ID: {} does not exist."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;delete_product&lt;/code&gt; function removes a product from storage by its ID. If the product doesn't exist, a message is logged.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 9: Implementing the Get All Products Operation
&lt;/h3&gt;

&lt;p&gt;Lastly, let's add a function to retrieve all products.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="n"&gt;ProductContract&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;get_all_products&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Vec&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;count_product&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u64&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="nf"&gt;.storage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.instance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;COUNT_PRODUCT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="nf"&gt;.unwrap_or&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;Vec&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;..=&lt;/span&gt;&lt;span class="n"&gt;count_product&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;Self&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get_product_by_id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="nf"&gt;.clone&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="nf"&gt;.push_back&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="n"&gt;products&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;get_all_products&lt;/code&gt; function iterates through all the stored products and returns them as a vector.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 10: Testing and Deploying the Contract
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In order to deploy the smartcontract you will need an account. You can either use the an account from the &lt;code&gt;Freighter Wallet&lt;/code&gt; or can configure an account named &lt;code&gt;alice&lt;/code&gt; in the testnet using the command:&lt;br&gt;
&lt;code&gt;soroban keys generate --global alice --network testnet&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can see the public key of account &lt;code&gt;alice&lt;/code&gt;:&lt;br&gt;
&lt;code&gt;soroban keys address alice&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;=&amp;gt; Go inside the &lt;code&gt;/product-crud&lt;/code&gt; directory and do the below mentioned steps:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Build the contract:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;soroban contract build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Alternte command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cargo build --target wasm32-unknown-unknown --release
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install Optimizer:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cargo install --locked soroban-cli --features opt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Build an Opmize the contract:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;soroban contract optimize --wasm target/wasm32-unknown-unknown/release/hello_world.wasm 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Steps to the Deploy smart-contract on testnet:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;deploy the smartcontract on the testnet and get deployed address of the smartcontract using the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stellar contract deploy --wasm target\wasm32-unknown-unknown\release\hello_world.wasm  --network testnet --source alice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Deployed address of this smartcontract:&lt;/em&gt;&lt;/strong&gt; &lt;code&gt;contract_address&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;*NOTE: If you get the XDR Error &lt;code&gt;error: xdr processing error: xdr value invalid&lt;/code&gt;, then follow this &lt;a href="https://stellar.org/blog/developers/protocol-21-upgrade-guide" rel="noopener noreferrer"&gt;article&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Invoke functions from the smart-contract:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;#### To invoke any of the function from the smartcontract you can use this command fromat.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;soroban contract invoke \
  --id &amp;lt;DEPLOYED_CONTRACT_ADDRESS&amp;gt; \
  --source &amp;lt;YOUR_ACCOUNT_NAME&amp;gt; \
  --network testnet \
  -- \
  &amp;lt;FUNCTION_NAME&amp;gt; --&amp;lt;FUNCTION_PARAMETER&amp;gt; &amp;lt;ARGUMENT&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are example &lt;code&gt;soroban contract invoke&lt;/code&gt; commands for each of the functions in the &lt;code&gt;ProductContract&lt;/code&gt; smart contract, using dummy data. Replace &lt;code&gt;&amp;lt;DEPLOYED_CONTRACT_ADDRESS&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;YOUR_ACCOUNT_NAME&amp;gt;&lt;/code&gt;, and other placeholders with actual values.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Create a Product
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;soroban contract invoke &lt;span class="nt"&gt;--id&lt;/span&gt; &amp;lt;DEPLOYED_CONTRACT_ADDRESS&amp;gt; &lt;span class="nt"&gt;--source&lt;/span&gt; &amp;lt;YOUR_ACCOUNT_NAME&amp;gt; &lt;span class="nt"&gt;--network&lt;/span&gt; testnet &lt;span class="nt"&gt;--&lt;/span&gt; create_product &lt;span class="nt"&gt;--name&lt;/span&gt; &lt;span class="s2"&gt;"Sample Product"&lt;/span&gt; &lt;span class="nt"&gt;--description&lt;/span&gt; &lt;span class="s2"&gt;"A description of the sample product."&lt;/span&gt; &lt;span class="nt"&gt;--price&lt;/span&gt; 1000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Get a Product by ID
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;soroban contract invoke &lt;span class="nt"&gt;--id&lt;/span&gt; &amp;lt;DEPLOYED_CONTRACT_ADDRESS&amp;gt; &lt;span class="nt"&gt;--source&lt;/span&gt; &amp;lt;YOUR_ACCOUNT_NAME&amp;gt; &lt;span class="nt"&gt;--network&lt;/span&gt; testnet &lt;span class="nt"&gt;--&lt;/span&gt; get_product_by_id &lt;span class="nt"&gt;--product_id&lt;/span&gt; 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Update a Product
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;soroban contract invoke &lt;span class="nt"&gt;--id&lt;/span&gt; &amp;lt;DEPLOYED_CONTRACT_ADDRESS&amp;gt; &lt;span class="nt"&gt;--source&lt;/span&gt; &amp;lt;YOUR_ACCOUNT_NAME&amp;gt; &lt;span class="nt"&gt;--network&lt;/span&gt; testnet &lt;span class="nt"&gt;--&lt;/span&gt; update_product &lt;span class="nt"&gt;--product_id&lt;/span&gt; 1 &lt;span class="nt"&gt;--new_name&lt;/span&gt; &lt;span class="s2"&gt;"Updated Product"&lt;/span&gt; &lt;span class="nt"&gt;--new_description&lt;/span&gt; &lt;span class="s2"&gt;"Updated description of the product."&lt;/span&gt; &lt;span class="nt"&gt;--new_price&lt;/span&gt; 1200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Delete a Product
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;soroban contract invoke &lt;span class="nt"&gt;--id&lt;/span&gt; &amp;lt;DEPLOYED_CONTRACT_ADDRESS&amp;gt; &lt;span class="nt"&gt;--source&lt;/span&gt; &amp;lt;YOUR_ACCOUNT_NAME&amp;gt; &lt;span class="nt"&gt;--network&lt;/span&gt; testnet &lt;span class="nt"&gt;--&lt;/span&gt; delete_product &lt;span class="nt"&gt;--product_id&lt;/span&gt; 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Permanently Delete a Product
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;soroban contract invoke &lt;span class="nt"&gt;--id&lt;/span&gt; &amp;lt;DEPLOYED_CONTRACT_ADDRESS&amp;gt; &lt;span class="nt"&gt;--source&lt;/span&gt; &amp;lt;YOUR_ACCOUNT_NAME&amp;gt; &lt;span class="nt"&gt;--network&lt;/span&gt; testnet &lt;span class="nt"&gt;--&lt;/span&gt; delete_product_permanently &lt;span class="nt"&gt;--product_id&lt;/span&gt; 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. Delete All Products
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;soroban contract invoke &lt;span class="nt"&gt;--id&lt;/span&gt; &amp;lt;DEPLOYED_CONTRACT_ADDRESS&amp;gt; &lt;span class="nt"&gt;--source&lt;/span&gt; &amp;lt;YOUR_ACCOUNT_NAME&amp;gt; &lt;span class="nt"&gt;--network&lt;/span&gt; testnet &lt;span class="nt"&gt;--&lt;/span&gt; delete_all_products
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explanation of Parameters
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--id &amp;lt;DEPLOYED_CONTRACT_ADDRESS&amp;gt;&lt;/code&gt;: The address where the smart contract is deployed.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--source &amp;lt;YOUR_ACCOUNT_NAME&amp;gt;&lt;/code&gt;: The account name used to invoke the contract.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--network testnet&lt;/code&gt;: The network on which the contract is deployed (e.g., &lt;code&gt;testnet&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;FUNCTION_NAME&amp;gt;&lt;/code&gt;: The function you want to invoke in the smart contract.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;FUNCTION_PARAMETER &amp;lt;ARGUMENT&amp;gt;&lt;/code&gt;: The parameters required by the function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Replace placeholders with actual values to interact with your deployed contract on the Stellar testnet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Congratulations! You've successfully created a Stellar smart contract that performs CRUD operations for managing products. This guide walked you through setting up a Rust project, defining the contract and product structure, and implementing each CRUD operation step by step. You can now use this knowledge to build more complex dApps on the Stellar network.&lt;/p&gt;

</description>
      <category>stellarchallenge</category>
    </item>
  </channel>
</rss>
