We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Campaign Logic.
Definition of Done:
Tasks:
Code Example:
#[account] pub struct Campaign { pub creator: Pubkey, // Creator's wallet address pub title: String, // Campaign title pub description: String, // Campaign description pub goal_amount: u64, // Funding goal in lamports pub current_amount: u64, // Current amount pledged pub start_date: i64, // Campaign start time pub end_date: i64, // Campaign end time pub status: u8, // 0 = active, 1 = completed, 2 = cancelled } #[derive(Accounts)] pub struct CreateCampaign<'info> { #[account(init, payer = creator, space = 8 + Campaign::MAX_SIZE, seeds = [b"campaign", creator.key().as_ref()], bump)] pub campaign: Account<'info, Campaign>, #[account(mut)] pub creator: Signer<'info>, pub system_program: Program<'info, System>, } pub fn create_campaign( ctx: Context<CreateCampaign>, title: String, description: String, goal_amount: u64, start_date: i64, end_date: i64, ) -> Result<()> { require!(end_date > start_date, ErrorCode::InvalidDates); require!(goal_amount > 0, ErrorCode::InvalidGoalAmount); let campaign = &mut ctx.accounts.campaign; campaign.creator = *ctx.accounts.creator.key; campaign.title = title; campaign.description = description; campaign.goal_amount = goal_amount; campaign.current_amount = 0; campaign.start_date = start_date; campaign.end_date = end_date; campaign.status = 0; // Active Ok(()) }
The text was updated successfully, but these errors were encountered:
jucoba
No branches or pull requests
Create Campaign Logic.
Definition of Done:
Tasks:
Code Example:
The text was updated successfully, but these errors were encountered: