I am learning Solana from the soldev.app. The code is taken from the StateManagement tutorial. After the pda_account is deserialized, there is written new values into its buffer. Shouldn't be a method to commit the changes to the pda_account besides the serialize method? I'm asking because this is the example code of the tutorial, and this is how it ends.

let mut account_data = try_from_slice_unchecked::<MovieAccountState>(&pda_account.data.borrow()).unwrap();
account_data.title = title;
account_data.rating = rating;
account_data.description = description;
account_data.is_initialized = true;

//this is the line im reffering to
account_data.serialize(&mut &mut pda_account.data.borrow_mut()[..])?;

1 Answer 1


You need no more than the last line. The serialize method writes to the account you pass into its argument, updating it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.