1

I have a mint account created from this script which utilizes Token2022 Program: Solana playground.. Now I am trying to create an ATA(Associated token account) by passing the mint account and user's public key.

const associatedTokenAccount = await getAssociatedTokenAddress( mintKeypair.publicKey, payer.publicKey );

When I log this, I get a newly created key. Now to initialize this key into an actual account on Solana blockchain I am using this code snippet: code snippet

But it is not getting initialized, also I have a question, since the mint account is initialized by Token2022 program, does the ATA also include token2022 as a seed? As in getAssociatedTokenAddress() it is hardcoded for token program to be TOKEN_PROGRAM_ID enter image description here

1
  • could you share the error logs
    – Jimii
    Commented May 8 at 15:58

1 Answer 1

0

When deriving an ATA for token-2022, you also need to provide the token-2022 program id. Try doing:

const associatedTokenAccount = await getAssociatedTokenAddress(
  mintKeypair.publicKey,
  payer.publicKey,
  false, // the default
  TOKEN_2022_PROGRAM_ID
);

See the source code at https://github.com/solana-labs/solana-program-library/blob/d1c03cc6164ebdeebef19190de28b7a71f4e4cb6/token/js/src/state/mint.ts#L162

1
  • Yes, I was able to do this, through this method. Thankyou!! Commented May 14 at 5:28

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.