This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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::*; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |