LogoLogo
  • For Students
    • Welcome
    • Live Classroom
    • Office Hours
    • Completing Assignments
    • Capstone Projects
    • Certification
  • Solana
    • Overview
    • Orientation Slides and Recording
    • Prerequisites
    • Cluster 1 -- Week 1
    • Cluster 2 -- Weeks 2 & 3
    • Cluster 3 -- Weeks 4 & 5
Powered by GitBook
On this page
  • Concepts for Cluster 1
  • Ownership & Borrowing
  • Structs
  • Enums
  • Types, Traits, Attributes
  • Storage, Vectors, Maps
  • Solana CLI and Builds/File/Crate/Package/Program Mgmt
  • Assignments
  • 1) Code Journals
  • 2) Code Challenges
  • 3) Capstone Brainstorming
  1. Solana

Cluster 1 -- Week 1

PreviousPrerequisitesNextCluster 2 -- Weeks 2 & 3

Last updated 2 years ago

Cluster one will focus on all concepts below. The materials below shall be reviewed on your own time and will be referenced throughout the cluster. Assignments can always be found in these sections.

Concepts for Cluster 1

1) Ownership/ Borrowing

2) Structs

3) Enums

4) Types, Traits/ Attributes

5) Storage, Vectors, Maps

6) Solana CLI and Builds/ File/Crate/ Package/ Program Mgmt

Ownership & Borrowing

Structs

Using Structs to Structure Related Data

Enums

Enums Tutorial

Types, Traits, Attributes

Storage, Vectors, Maps

Solana CLI and Builds/File/Crate/Package/Program Mgmt

Assignments

1) Code Journals

Mastery of a skill comes from immersing yourself in the study and use of it in many different ways.

For the Code Study Journal, you will need to complete 3 code journals the first week for codebases from Native Rust. Second week is the same example programs in Anchor. For the third week, you will do a compare and contrast video between the Native and the Anchor versions all of these are due by Sunday midnight UTC at the end of each week). You will send these to GitHub-as prescribed for all Cohort work [NOTE: each journal entry should focus on 30-50 lines of code- meaning your total annotations should be between 90-150. If you end up doing a single contract that is 90-150 lines, that works for all 3 that week]

Here are the steps to complete each one:

  1. Select a piece of code/ smart contract. The first week, we will continue to focus on Native Rust code in Solana Programs- then we will move to Anchor in week two. Week three will be a video walkthrough of the comparison between the two. Please choose from these repos for the process. Choose from the following options since these all have both Native and Anchor examples for programs

    Code Journals for Cluster I

    Native Versions

  2. Annotate the code- in other words, make notes on the document explaining what is happening through the code.

  • What are the concepts (borrowing, ownership, vectors etc)

  • What is the organization?

  • What is the contract doing? What is the mechanism?

  • How could it be better? More efficient? Safer?

  • As we shift to week 2 (CLUSTER II- this one is two weeks long), your lens of Native Rust -> Anchor should be explored, annotated, and analyzed.

3. Make a video of your code study,for week three (CLUSTER II), you will make a video comparing and contrasting Native vs. Anchor programs, and show an example of how you made the code better, test, compile, and deploy it on video.

We ask that you interpret and apply these instructions in the way you understand them. Not everyone will do so the same way. There are no wrong answers- the only way to fail this part is to not do it and ship on time.

Engagement through reading, thinking, and writing about code in this way leads to your own discovery of the how, what, where, when, why of smart contracts- architecture & mechanism .

We are interested in how YOU do this process. The more you immerse and think deeply about the code, the more expert you will become.

All Code Journals must completed in the WBA Organization repo in GitHub! Video should be submitted via Google Classroom on the assignment link therein

Sample Code Journal

Annotations (In line & Comment)

/From Program-Examples: Counter Program 

use borsh::{BorshDeserialize, BorshSerialize};			                                        / 
use solana_program::{						                                         your annotations to 
    account_info::{next_account_info, AccountInfo},			                                the side like this. 
    declare_id,
    entrypoint::ProgramResult,
    msg,
    program::{invoke, invoke_signed},
    program_error::ProgramError,
    pubkey::Pubkey,
    system_instruction,
};



mod state;
use state::*;

declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

Adding Additional Questions

Copy the questions below and provide the answer for each Code Journal you complete.

  1. What are the concepts (borrowing, ownership, vectors etc)

  2. What is the organization?

  3. What is the contract doing? What is the mechanism?

  4. How could it be better? More efficient? Safer?

  5. The code could be safer and better if…..

Sample Code Journal (Cont'd)

//From Program-Examples: Counter Program 

use borsh::{BorshDeserialize, BorshSerialize};	      \\You can simply write                                                                                                 
                                                      annotations off to the side

use solana_program::{						                                          
    account_info::{next_account_info, AccountInfo},			                                 
    declare_id,
    entrypoint::ProgramResult,
    msg,
    program::{invoke, invoke_signed},
    program_error::ProgramError,
    pubkey::Pubkey,
    system_instruction,
};

// OR, you can enter your annotations in comment form- be sure we can distinguish between your annotations and the existing comments in the codebase

mod state;
use state::*;

declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

//Code Journal Summary:

- What are the concepts (borrowing, ownership, vectors etc)
    The Concepts in the Code are… they are —---
- What is the organization?
    The code is organized……
- What is the contract doing? What is the mechanism? 
    The contract is a staking contract and the mechanism…
- How could it be better? More efficient? Safer? 
    The code could be safer and better if…..

Have other ideas of how to do this process? We are always open to suggestions.

Ultimately, write everything that comes to your mind as much as you can- by reading, thinking about what you see, processing it, and outputting your thoughts, questions, comments, revision-suggestions, you are gaining mastery of the concepts.

2) Code Challenges

Make sure you push your hacked code from class to the WBA Github with correct naming conventions.

3) Capstone Brainstorming

You Capstone LOI will be due at the end of the next cluster (3 weeks into course).

Acct Check NAT
CPI NAT HAND
CPI NAT LEVER
PROC-INSTR-NAT
PDA NAT
Rust - Ownership
Logo
Using Structs to Structure Related Data - The Rust Programming Language
Logo
Rust - Enums
Logo
Generic Types, Traits, and Lifetimes - The Rust Programming Language
Logo
Storing Lists of Values with Vectors - The Rust Programming Language
Logo
Protocol Overview | Solana Program Library Docs
Logo
GitHub - solana-labs/solana-program-library: A collection of Solana-maintained on-chain programsGitHub
SolDev - Bootcamp - Chicago Jan 2022soldevapp
Logo
Logo