Created
December 24, 2023 03:53
-
-
Save gentlyawesome/cae430c0d82e9a20aedc7d87de8bc261 to your computer and use it in GitHub Desktop.
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!("5gaQPYyZV2EzyMEG6z2a1B5ZpdXxGmru7eEV5pNZJeNv"); | |
#[program] | |
pub mod mycalculator { | |
use anchor_lang::solana_program::entrypoint::ProgramResult; | |
use super::*; | |
pub fn create(ctx: Context<Create>, init_message: String) -> ProgramResult { | |
let calculator = &mut ctx.accounts.calculator; | |
calculator.greeting = init_message; | |
Ok(()) | |
} | |
} | |
#[derive(Accounts)] | |
pub struct Create<'info> { | |
#[account(init, payer=user, space=264)] | |
pub calculator: Account<'info, Calculator>, | |
#[account(mut)] | |
pub user: Signer<'info>, | |
pub system_program: Program<'info, System>, | |
} | |
#[account] | |
pub struct Calculator { | |
pub greeting: String, | |
pub results: i64, | |
pub remainder: i64, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment