• Discover
  • Partner with us
  • Chapters
  • Blog

Learn everything about Stellar

Rust Walkthrough
Rust Basic Homework

Course Intro
Section Overview
Stellar Intro
Creating Wallet for Stellar
Soroban Intro
Setting up the development environment
Soroban First Code Walkthrough
Deploy to the Stellar Testnet
Section Summary

Section Overview
Single offer Example
Time Lock
Atomic Swap
Section Summary

Submit Your Final Project

Task Details

In this homework, you will create a simulation of a market system. This system will include customers and products, and provide an interface for customers to perform certain actions.

Steps

  • Define Customer and Product Structures:
  • Define structures (structs) to represent customers and products.
  • Create a structure for each customer containing information such as name, surname, and balance.
  • Create a structure for each product containing information such as name, price, and stock quantity.
  • Create Market Functions:
  • Implement functions to perform basic market operations such as adding customers, adding products, and making purchases.
  • Include a function to allow customers to purchase a specific product by checking their balances.
  • Develop the Main Program:
  • Instantiate sample customers and products.
  • Create a loop to provide a user interface for customers to perform market operations.

Checklist

  • Define and create customer and product structures.
  • Implement market functions and test each one.
  • Write and execute the main program.
  • Provide a user interface for customers to perform market operations.

Code Template

struct Customer {

   // Complete the struct according to the requested parameters

}

struct Product {

   // Complete the struct according to the requested parameters

}

// Market functions

impl Customer {

    // Function for purchasing a product

    fn buy_product(&mut self, product: &mut Product, quantity: u32) -> bool {

        //If the product is available in sufficient quantity in stock and the customer has enough balance to buy it, purchase the product and update the customer's balance. Return true if the purchase is successful, false otherwise.

       

    }

}

// Main program

fn main() {

   

    let mut customer1 = Customer {

       // Create sample customers

    };

   

    let mut customer2 = Customer {

      // Create sample customers

    };

   

    let mut product = Product {

      // Create a sample product

    };

    // Customers' product purchase operations

    println!("Customer 1 is buying a product...");

    if [customer1.buy](http://customer1.buy)\_product(&mut product, 3) {

        println!("Customer 1 successfully purchased the product.");

    } else {

        println!("Customer 1 couldn't purchase the product.");

    }

    println!("Customer 2 is buying a product...");

    if [customer2.buy](http://customer2.buy)\_product(&mut product, 8) {

        println!("Customer 2 successfully purchased the product.");

    } else {

        println!("Customer 2 couldn't purchase the product.");

    }

}

Task

Submit your work to complete this lesson.

Join the project workspace to share your solution and receive feedback.

Previous
Next

Lesson discussion

Swap insights and ask questions about “Learn everything about Stellar”.

Enroll to participate
Start the course to unlock the discussion. Enrolling helps us keep conversations relevant to learners.
WebsiteDiscoverPartner with UsBlogEvents
Discover
CoursesCircleRustSoliditySolanaWeb3 FundamentalsBlockchain Basics
CompanyAbout UsBrand GuidelineFAQsTerms of UsePrivacy PolicyGDPR NoticeCookies
Don't miss any update!

Disclaimer: The information, programs, and events provided on https://risein.com is strictly for upskilling and networking purposes related to the technical infrastructure of blockchain platforms. We do not provide financial or investment advice, nor do we make any representations regarding the value, profitability, or future price of any blockchain or cryptocurrency. Users are encouraged to conduct their own research and consult with licensed financial professionals before engaging in any investment activities. https://risein.com disclaims any responsibility for financial decisions made by users based on the information provided here.

© 2026 Rise In, All rights reserved