Created
February 23, 2022 17:17
-
-
Save merlox/cbcef1e30dbd7ca2ebe52394c507a425 to your computer and use it in GitHub Desktop.
The progress so far
This file contains 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 solana_global_article { | |
use super::*; | |
pub fn initialize(ctx: Context<Initialize>) -> ProgramResult { | |
// Get the article | |
let article_account = &mut ctx.accounts.article; | |
// Initialize the variables (this is required) | |
article_account.content = ("").to_string(); | |
Ok(()) | |
} | |
} | |
#[derive(Accounts)] | |
pub struct Initialize<'info> { | |
#[account( | |
init, | |
payer = person_that_pays, | |
space = 8 // account discriminator | |
+ 32 // pubkey | |
+ 10000 // make the message max 10k bytes long | |
)] | |
pub article: Account<'info, Article>, | |
#[account(mut)] | |
pub person_that_pays: Signer<'info>, | |
pub system_program: Program<'info, System>, | |
} | |
#[account] | |
pub struct Article { | |
pub content: String, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment