I want to initialize solana program through IDL using rust (anchor-client) program as same as we do in JS

let programNetworkDemand = new Program(

I didn't able to initailize program in anchor_client

  • That's not Rust code. Have you tried doing it in Rust yet? Please post what you have tried and the error you are getting so we can help.
    – sohrab
    Commented Jul 14, 2022 at 11:19
  • @sohrab The code snippet I shared above is TS code I need to implement same thing on rust but I am unable to find how can I initilaze program in rust Commented Jul 14, 2022 at 12:25
  • as far as am aware this does not exist in the anchor rust client (it does not get the same love the anchor-ts gets xD) , the feature you are in search of only exist on the ts side am not sure on this, hopefully someone with more idea can add to this. Commented Jul 14, 2022 at 12:57
  • @NabeelNaveed is this still the case or there's a way to generate rust types automatically from IDLs for Instructions decoding? Commented Apr 3 at 21:51
  • 1
    hey @IvanTemchenko it is possible, refer to my answer here : solana.stackexchange.com/a/12409/230 Commented Apr 5 at 18:13

1 Answer 1


Unfortunately, anchor_client is not IDL-aware. It is intended for scenarios where you have access to the source code (or crate) of the program you are calling.

You can see an example of this the Anchor github repo:

    .accounts(basic_2_accounts::Create {
        counter: counter.pubkey(),
        user: authority,
        system_program: system_program::ID,
    .args(basic_2_instruction::Create { authority })

Here, the Account and argument structs from the Tutorial 2 program have been used to compose the transaction.

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.