Skip to main content
deleted 57 characters in body
Source Link

I have the same problem. try add system_program_id & spl_token_id account:

        invoke(
        &spl_associated_token_account::instruction::create_associated_token_account(
            acc_funder_.key,
            acc_wallet_.key,
            acc_mint_.key,
        ),
        &[
            acc_funder_.clone(),
            acc_wallet_.clone(),
            acc_mint_.clone(),
            tacc_wallet_.clone(),
            acc_system_program_.clone(), // <-
            acc_spl_token_.clone(), // <-
        ]
    )?;

because create_associated_token_account wants also 2 implicit parameters

pub fn create_associated_token_account(
    funding_address: &Pubkey,
    wallet_address: &Pubkey,
    spl_token_mint_address: &Pubkey,
) -> Instruction {
    let associated_account_address = get_associated_token_address(wallet_address, spl_token_mint_address);

    let instruction_data = AssociatedTokenAccountInstruction::Create {};

Instruction {
    program_id: id(),
    accounts: vec![
        AccountMeta::new(*funding_address, true),
        AccountMeta::new(associated_account_address, false),
        AccountMeta::new_readonly(*wallet_address, false),
        AccountMeta::new_readonly(*spl_token_mint_address, false),
        AccountMeta::new_readonly(solana_program::system_program::id(), false), // <-
        AccountMeta::new_readonly(spl_token::id(), false), // <-
    ],
    data: instruction_data.try_to_vec().unwrap(),
    }
}

maybe you solved it in a different way, if so, write how.

I have the same problem. try add system_program_id & spl_token_id account:

        invoke(
        &spl_associated_token_account::instruction::create_associated_token_account(
            acc_funder_.key,
            acc_wallet_.key,
            acc_mint_.key,
        ),
        &[
            acc_funder_.clone(),
            acc_wallet_.clone(),
            acc_mint_.clone(),
            tacc_wallet_.clone(),
            acc_system_program_.clone(), // <-
            acc_spl_token_.clone(), // <-
        ]
    )?;

because create_associated_token_account wants also 2 implicit parameters

pub fn create_associated_token_account(
    funding_address: &Pubkey,
    wallet_address: &Pubkey,
    spl_token_mint_address: &Pubkey,
) -> Instruction {
    let associated_account_address = get_associated_token_address(wallet_address, spl_token_mint_address);

    let instruction_data = AssociatedTokenAccountInstruction::Create {};

Instruction {
    program_id: id(),
    accounts: vec![
        AccountMeta::new(*funding_address, true),
        AccountMeta::new(associated_account_address, false),
        AccountMeta::new_readonly(*wallet_address, false),
        AccountMeta::new_readonly(*spl_token_mint_address, false),
        AccountMeta::new_readonly(solana_program::system_program::id(), false), // <-
        AccountMeta::new_readonly(spl_token::id(), false), // <-
    ],
    data: instruction_data.try_to_vec().unwrap(),
    }
}

maybe you solved it in a different way, if so, write how.

I have the same problem. try add system_program_id & spl_token_id account:

        invoke(
        &spl_associated_token_account::instruction::create_associated_token_account(
            acc_funder_.key,
            acc_wallet_.key,
            acc_mint_.key,
        ),
        &[
            acc_funder_.clone(),
            acc_wallet_.clone(),
            acc_mint_.clone(),
            tacc_wallet_.clone(),
            acc_system_program_.clone(), // <-
            acc_spl_token_.clone(), // <-
        ]
    )?;

because create_associated_token_account wants also 2 implicit parameters

pub fn create_associated_token_account(
    funding_address: &Pubkey,
    wallet_address: &Pubkey,
    spl_token_mint_address: &Pubkey,
) -> Instruction {
    let associated_account_address = get_associated_token_address(wallet_address, spl_token_mint_address);

    let instruction_data = AssociatedTokenAccountInstruction::Create {};

Instruction {
    program_id: id(),
    accounts: vec![
        AccountMeta::new(*funding_address, true),
        AccountMeta::new(associated_account_address, false),
        AccountMeta::new_readonly(*wallet_address, false),
        AccountMeta::new_readonly(*spl_token_mint_address, false),
        AccountMeta::new_readonly(solana_program::system_program::id(), false), // <-
        AccountMeta::new_readonly(spl_token::id(), false), // <-
    ],
    data: instruction_data.try_to_vec().unwrap(),
    }
}
Source Link

I have the same problem. try add system_program_id & spl_token_id account:

        invoke(
        &spl_associated_token_account::instruction::create_associated_token_account(
            acc_funder_.key,
            acc_wallet_.key,
            acc_mint_.key,
        ),
        &[
            acc_funder_.clone(),
            acc_wallet_.clone(),
            acc_mint_.clone(),
            tacc_wallet_.clone(),
            acc_system_program_.clone(), // <-
            acc_spl_token_.clone(), // <-
        ]
    )?;

because create_associated_token_account wants also 2 implicit parameters

pub fn create_associated_token_account(
    funding_address: &Pubkey,
    wallet_address: &Pubkey,
    spl_token_mint_address: &Pubkey,
) -> Instruction {
    let associated_account_address = get_associated_token_address(wallet_address, spl_token_mint_address);

    let instruction_data = AssociatedTokenAccountInstruction::Create {};

Instruction {
    program_id: id(),
    accounts: vec![
        AccountMeta::new(*funding_address, true),
        AccountMeta::new(associated_account_address, false),
        AccountMeta::new_readonly(*wallet_address, false),
        AccountMeta::new_readonly(*spl_token_mint_address, false),
        AccountMeta::new_readonly(solana_program::system_program::id(), false), // <-
        AccountMeta::new_readonly(spl_token::id(), false), // <-
    ],
    data: instruction_data.try_to_vec().unwrap(),
    }
}

maybe you solved it in a different way, if so, write how.