Questions and answers

How can I deserialize the account in the Rust fronted?

Text size
The issue with the missing #[max_len(32)] is that the serialized account contains an string padded with 0 bytes to make 32 bytes, whereas the deserializing struct tries to deserialize only however many bytes long your string actually is and then the remaining 0 bytes mess it up for deserializing the following fields. To fix this, I recommend using declare_program! from anchor_client. That way you don't need to implement the same struct by hand in your program and client and you get deserialization implemented for you for free. Copy pasting from this question: declare_program!(my_program); use my_program::{ID, accounts::Proposal}; use anchor_client::Client; let cl = Client::new_with_options( cluster, fee_payer, CommitmentConfig::confirmed(), ); let p = cl.program(ID).unwrap(); let acc_state: Proposal = p.account().await?; If you can't do this though, I'd recommend using BorshDeserialize::deserialize as like I said your problem is having too many bytes. Proposal::deserialize(&mut &data[..]).unwrap(); Note that this will mutate your underlying byte array to point to the remaining bytes though. I'm guessing this is fine as you probably won't use those same bytes for anything else, but just as an fyi.
Continue exploringData catalogueSearch