If I try to create a transaction using declare_program! for accounts and args and anchor_client for building the transaction:

use anchor_lang::prelude::*;
use my_program::client::accounts::MyInstruction as MyInstructionAccs;
use my_program::client::args::MyInstruction as MyInstructionArgs;
use anchor_client::Program;
use anchor_lang::prelude::*;
use solana_sdk::signer::Signer;

pub fn send_startup_tx<C: Deref<Target = impl Signer> + Clone>(
    p: Program<C>,
    acc: Pubkey,
    param: u32,
) {
    let accs = MyInstructionAccs {
        acc1: acc,
    let args = MyInstructionArgs { 
        arg1: param,
    let a = p.request().accounts(accs).args(args)

This unfortunately doesn't build, with the following error

the trait bound `__client_accounts_my_instruction::MyInstruction: anchor_client::anchor_lang::ToAccountMetas` is not satisfied

If I do cargo expand, I can also see why: declare_program! generates an impl for anchor_lang::ToAccountMetas, but not for anchor_client::anchor_lang::ToAccountMetas even though these two are the exact same in practice.

I've tried switching my import at the top to use anchor_client::anchor_lang::declare_program; but it still gives the same error. Any idea on how to fix this?

1 Answer 1


Turns out I was just using two different versions of anchor_client and anchor_lang. Made sure both are the same version, and it works perfectly now.

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.