1

There are two program ids in the code base of solana-program-library. To be precise:

ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'
TOKEN_PROGRAM_ID = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'

And I do not get the idea of separating these two programs and the general use of them. I mean, I'm well aware of the idea of tokens. But why there are two programs? I have flicked through the code and have noticed such a thing, that there is no js client to associated-token-account, only program. And it seems that it is used only as a part of the @solana/spl-token js client.

As far as I can get it, ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID serves only one purpose, this is creation of new accounts. Plus, there is fn process_recover_nested(...) which usage is obscure for me.

So I would appreciate someone's explanation of this differentiation and usage purposes.

1 Answer 1

1

Every token needs to be held in an associated token account. This is mapped to a wallet. When minting or transferring, you interact with both of these programs. And I believe process_recover_nested() helps with closing these out so you can recover the SOL balance after you're done minting or transferring a token.

Here's more info on each one:

Associated Token Accounts - defines the convention and provides the mechanism for mapping the user's wallet address to the associated token accounts they hold.

Token Program - This program defines a common implementation for Fungible and Non Fungible tokens.

Closing Accounts process_recover_nested() I believe exists to transfer back the SOL and close out the accounts so you can recover the rent/storage of unneeded accounts after minting or transferring. Note: You can't recover this if you don't use a candy machine or create/own the ATA. For example, if you airdrop directly to a users wallet, you'd be creating and funding the ATA for each token on their behalf, that you don't own, and can't close.

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.