0

In my program, suppose I want to take tokens from a user, or send tokens to that user, etc. Should I support any token accounts (given the mint and the owner matches of course), or only the associated token accounts? What are the pros and cons to both approach? What's the best practice here?

1 Answer 1

1

The best option is to default to associated token accounts in your tooling and clients, but support any token account if it's provided to the program, similar to how the spl-token command-line utility works.

There, you can do: spl-token transfer <MINT_ADDRESS> <AMOUNT> <RECIPIENT_WALLET_ADDRESS>, which defaults to associated token accounts everywhere.

You can also do: spl-token transfer --from <TOKEN_ACCOUNT_ADDRESS> <AMOUNT> <RECIPIENT_TOKEN_ACCOUNT_ADDRESS>.

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.