inititialize_mint instruction failed: invalid account data for instruction

  python, solana

first and foremost, I presume that initialize_mint is the process to create a token.

I have this program written that seems to me to be ok without an issue:


use solana_program::{
    account_info::{next_account_info, AccountInfo},
    entrypoint,
    entrypoint::ProgramResult,
    pubkey::Pubkey,
    program::{invoke},
};

use spl_token::{instruction::*};

entrypoint!(process_instructions);

pub fn process_instructions(program_id: &Pubkey, accounts: &[AccountInfo], _: &[u8]) -> ProgramResult{
    let account_info_iter = &mut accounts.iter();

    let mint_account_info = next_account_info(account_info_iter)?;
    let rent_account_info = next_account_info(account_info_iter)?;


    let mint_authority_pubkey = program_id.clone();
    let freeze_authority_pubkey = program_id.clone();
    let decimals = 0;
    let token_program_info = next_account_info(account_info_iter)?;
    invoke(
        &initialize_mint(&token_program_info.key, &mint_account_info.key,  &mint_authority_pubkey, Some(&freeze_authority_pubkey), decimals)?,
        &[mint_account_info.clone(), rent_account_info.clone(), token_program_info.clone()]
    )?;

    Ok(())
}

But then when I proceed to call it from the client, I am using this code:

spl_program_meta  = AccountMeta(TOKEN_PROGRAM_ID, False, False)
rent_account_meta = AccountMeta(solana.sysvar.SYSVAR_RENT_PUBKEY, False, False)
mint_account_meta = AccountMeta(Keypair.generate().public_key, False, True)

accounts = [
    mint_account_meta,
    rent_account_meta,
    spl_program_meta
    ]


transaction = Transaction()
transaction.add(TransactionInstruction(
    accounts,
    program_id,
    bytes([])
))

client.send_transaction(transaction, payer_keypair)

running this give me the error: enter image description here

What is the account data I am getting wrong please?

Source: Python Questions

LEAVE A COMMENT