1

I am trying to derive AccountInfo from given public key on Rust, Is there any similar anchor function available like getParsedAccountInfo from solana/web3 library?

2 Answers 2

1

The official solana_account_decoder crate can help you.

1
  • which function can be used for AccountInfo parsing?
    – blackhorse
    Commented Jan 23 at 14:12
1

Yes! The rpc client provided by solana-rpc-client has get_account_with_config that lets you specify it:

let account_address = Pubkey::new(...);
let rpc_client = solana_rpc_client::rpc_client::RpcClient("...");
let account = rpc_client.get_account_with_config(
    &account_address,
    solana_rpc_client_api::config::RpcAccountInfoConfig {
        encoding: Some(solana_account_decoder::UiAccountEncoding::JsonParsed),
        ..Default::default()
    }
);

This is actually what getParsedAccountInfo is doing under the hood.

More info at https://docs.rs/solana-rpc-client/latest/solana_rpc_client/rpc_client/struct.RpcClient.html#method.get_account_with_config

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.