Im getting this error "Transaction simulation failed: Error processing Instruction 0: incorrect program id for instruction" I think its because Im passing in the same account twice one as signer and the other time as one of the seeds for the associated account. Is there any way to make it work?
public static TransactionInstruction createAssociatedTokenAccount(PublicKey funder, PublicKey receiver) throws Exception {
PublicKey.ProgramDerivedAddress assoc = getAssociatedTokenAddress(receiver,funder);
byte[]b= new byte[Integer.valueOf(0).byteValue()];
PublicKey assocTokenProgram=new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
List<AccountMeta> metas= new ArrayList<>();
metas.add(new AccountMeta(funder,true,true));
metas.add(new AccountMeta(assoc.getAddress(),false,true));
metas.add(new AccountMeta(receiver,false,false));
metas.add(new AccountMeta(funder,false,false));
metas.add(new AccountMeta(SystemProgram.PROGRAM_ID,false,false));
metas.add(new AccountMeta(new PublicKey(TOKEN_PROGRAM_ID),false,false));
metas.add(new AccountMeta(Sysvar.SYSVAR_RENT_ADDRESS,false,false));
TransactionInstruction instruction= new TransactionInstruction(assocTokenProgram,metas,b);
return instruction;
}