async createUserAtaAccount(){
try{
const programId = new PublicKey(this.USDC_MINT_ADDRESS);
const [PDA, bump] = PublicKey.findProgramAddressSync([], programId);
console.log("PDA::::",PDA.toString());
console.log("PDA::::",bump);
const associatedToken = getAssociatedTokenAddressSync(
new PublicKey(this.USDC_MINT_ADDRESS),
new PublicKey(this.walletAdress),
false
);
let tx= new Transaction();
tx.add(
createAssociatedTokenAccountInstruction(
new PublicKey(this.walletAdress), // payer
associatedToken, // ata
new PublicKey(this.walletAdress), // owner
new PublicKey(this.USDC_MINT_ADDRESS),
),
)
tx.feePayer = new PublicKey(this.walletAdress);
const blockhashObj = await this.connection.getRecentBlockhash();
console.log('blockhashObj ::::',blockhashObj)
tx.recentBlockhash = await blockhashObj.blockhash;
const signed = await window.solana.signTransaction(tx);
console.log('signed.serialize() ::::',signed.serialize())
let signature = await this.connection.sendRawTransaction(signed.serialize());
// Confirm whether the transaction went through or not
let hash= await this.connection.confirmTransaction(signature);
// console.log('signed:::::',signed);
console.log('hash:::::',hash);
}catch (e){
console.error("createUserAssAccount::::: ",e.toString());
}
},[enter image description here](https://i.sstatic.net/53gaWKFH.png)
callback error :createUserAssAccount::::: Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 2: Provided owner is not allowed
I want to create a usdc token account
New contributor
vpnjh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.