• 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 invoke another project to transfer tokens.

Here is the template you should be using for this project.

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

solana_program::entrypoint!(process_instruction);
pub fn process_instruction(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    _instruction_data: &[u8],
) -> ProgramResult {
    // Create an iterator to safely reference accounts in the slice
    let account_info_iter = &mut accounts.iter();

    // As part of the program specification the instruction gives:
    let source_info = next_account_info(account_info_iter)?; // 1.
    let mint_info = next_account_info(account_info_iter)?; // 2.
    let destination_info = next_account_info(account_info_iter)?; // 3.
    let authority_info = next_account_info(account_info_iter)?; // 4.
    let token_program_info = next_account_info(account_info_iter)?; // 5.

    // In order to transfer from the source account, owned by the program-derived
    // address, we must have the correct address and seeds.
    let (expected_authority, bump_seed) = Pubkey::find_program_address(&[b"authority"], program_id);
    if expected_authority != *authority_info.key {
        return Err(ProgramError::InvalidSeeds);
    }

    // The program transfers everything out of its account, so extract that from
    // the account data.
    let source_account = Account::unpack(&source_info.try_borrow_data()?)?;
    let amount = source_account.amount;

    // The program uses `transfer_checked`, which requires the number of decimals
    // in the mint, so extract that from the account data too.
    let mint = Mint::unpack(&mint_info.try_borrow_data()?)?;
    let decimals = mint.decimals;

    // Invoke the transfer
    msg!("Attempting to transfer {} tokens", amount);
    invoke_signed(
        &transfer_checked(
            token_program_info.key,
            source_info.key,
            mint_info.key,
            destination_info.key,
            authority_info.key,
            &[], // no multisig allowed
            amount,
            decimals,
        )
        .unwrap(),
        &[
            source_info.clone(),
            mint_info.clone(),
            destination_info.clone(),
            authority_info.clone(),
            token_program_info.clone(), // not required, but better for clarity
        ],
        &[&[b"authority", &[bump_seed]]],
    )
}
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