1

If I have my program idl imported using declare_program! how can I fetch and parse an on-chain account using it?

1 Answer 1

1

Figured it out. We can do:

declare_program!(my_program);
use my_program::{ID, accounts::MyAccount};

let cl = Client::new_with_options(
    cluster,
    fee_payer,
    CommitmentConfig::confirmed(),
);
let p = cl.program(ID).unwrap();
let acc_state: MyAccount = p.account(<Pubkey pointing to the account>).await?;

Your Answer

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

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