• Discover
  • Partner with us
  • Chapters
  • Blog

Learn everything about Solana

Course Introduction
Solana Introduction
Solana Smart Contract Fundamentals - Transactions
Solana Smart Contract Fundamentals - Instructions
Solana Smart Contract Fundamentals - Accounts
Solana Smart Contract Fundamentals - Program Derived Addresses (PDAs)

Installation Rust
Counter I - Implementing State and Instructions
Counter II - Implementing Process Instruction
Counter III - Build & Test
Submit Your Homework 1: Update Increment and Decrement Functions

Token Transfer I - Implementing process_instruction
Token Transfer II - Testing
Submit Your Homework 2: Change Transfer Amount

What Are We Going to Build?
Review I - Implementing State
Review II - Defining Instructions
Review III - Implementing Add_Review
Review IV - Implementing Update_Review
Review V - Build & Deploy
Review VI - Frontend

Build Your Final Project

In this lesson, we will take a look at how we can define the the state of our project.

You can click here for Solana Playground.

Here is the changes we have made to state.rs in this video:

use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::program_error::ProgramError;
use solana_program::program_pack::{IsInitialized, Sealed};
use thiserror::Error;

#[derive(BorshSerialize, BorshDeserialize)]
pub struct AccountState {
    pub is_initialized: bool,
    pub rating: u8,
    pub description: String,
    pub title: String,
}

impl Sealed for AccountState {}

impl IsInitialized for AccountState {
    fn is_initialized(&self) -> bool {
        self.is_initialized
    }
}

#[derive(Debug, Error)]
pub enum ReviewError {
    #[error("Account not initialized yet")]
    UninitializedAccount,

    #[error("PDA derived does not equal PDA passed in")]
    InvalidPDA,

    #[error("Rating greater than 10 or less than 1")]
    InvalidRating,
}

impl From<ReviewError> for ProgramError {
    fn from(e: ReviewError) -> Self {
        ProgramError::Custom(e as u32)
    }
}
Previous
Next

Lesson discussion

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

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