Write the create_entry instruction. You must initialize a PDA using the author's public key and the journal title as seeds.
While we defined #[max_len(1000)] for the message, if the user only writes "Hello", allocating 1000 bytes is a waste of rent! We should only allocate the space actually needed for the string they pass in.
A string in Rust requires 4 bytes to store its length, plus 1 byte for every character.
#[derive(Accounts)]
#[instruction(title: String, message: String)]
pub struct CreateEntry<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(
init,
payer = owner,
// 8 (discriminator) + 32 (pubkey) + (4 + title.len()) + (4 + message.len())
space = 8 + 32 + (4 + title.len()) + (4 + message.len()),
seeds = [title.as_bytes(), owner.key().as_ref()],
bump
)]
pub journal_entry: Account<'info, JournalEntryState>,
pub system_program: Program<'info, System>,
}
Implement the logic to save the title, message, and owner to the PDA!