Skip to content

Instantly share code, notes, and snippets.

View yuhcee's full-sized avatar
💭
If you are going through hell, keep going!

Uchenna Egbo yuhcee

💭
If you are going through hell, keep going!
View GitHub Profile
@yuhcee
yuhcee / pda_cpi_vault.rs
Created August 28, 2025 16:03
An Anchor PDA/CPI vault program for deposits and settlements
use anchor_lang::prelude::*;
use anchor_spl::token::{self, Mint, Token, TokenAccount, Transfer};
use anchor_spl::associated_token::{self, AssociatedToken};
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
#[program]
pub mod pda_cpi_vault {
use super::*;
@yuhcee
yuhcee / anchor_poll.rs
Created August 28, 2025 16:01
An Anchor poll program with create and vote instructions
use anchor_lang::prelude::*;
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
#[program]
pub mod anchor_poll {
use super::*;
pub fn create_poll(ctx: Context<CreatePoll>, question: String, options: Vec<String>) -> Result<()> {
let poll = &mut ctx.accounts.poll;
@yuhcee
yuhcee / anchor_calculator.rs
Created August 28, 2025 16:00
A basic Anchor calculator program
use anchor_lang::prelude::*;
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
#[program]
pub mod anchor_calculator {
use super::*;
pub fn add(ctx: Context<Calculator>, a: i64, b: i64) -> Result<()> {
let result = a + b;
@yuhcee
yuhcee / rust_calculator.rs
Last active August 28, 2025 15:59
A simple Rust command-line calculator
use std::io;
fn main() {
println!("Simple Rust Calculator");
println!("--------------------");
loop {
let mut input = String::new();
println!("Enter the first number:");
io::stdin().read_line(&mut input).expect("Failed to read line");