Skip to main content
9 votes

Creating an Associated Token Account via Solana Program

try using the init_if_needed constraint here's a Solpg reference you can test: https://beta.solpg.io/631a439777ea7f12846aee89 #[program] mod example { use super::*; pub fn initialize(ctx: ...
john's user avatar
  • 7,794
3 votes

InterfaceAccount<'_, TokenAccount> fails to create Associated Token Account

Your provided JS client code shows: await program.methods .createAta() .accounts({ /* .. */ userAta: getAssociatedTokenAddressSync(mint, user:USER.publickey), }); It should be: await ...
Joe C's user avatar
  • 1,116
2 votes

"Program log: Instruction: GetAccountDataSize", "Program log: Error: IncorrectProgramId", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA

If you're running into that error during GetAccountDataSize, I'm almost 100% sure it's this line: https://github.com/solana-labs/solana-program-library/blob/c94eeec63bdada46453eb46d0e7add4c504b1799/...
Jon C's user avatar
  • 19.6k
2 votes
Accepted

Do I have to explicitly create a USDC account to be able to receive USDC coins?

When you send USDC to a wallet address, the sender has to pay to create the linked token account (USDC associated token account for this particular wallet address). if the said token account already ...
Effe2's user avatar
  • 1,607
2 votes

Do I have to explicitly create a USDC account to be able to receive USDC coins?

No, you do not. Sending some USDC to that address should do this for you. Most wallets will do this for you. Also, make sure that the signer has some sol to cover the tx fees.
Jimii's user avatar
  • 7,712
2 votes
Accepted

Buy using TokenAccount with init errors on second call with "Provided owner is not allowed"

In anchor, when you are creating an account with init burt you are not sure if it already exists (like in the second buy, or for any associated token account) it's better to use init_if_needed. It ...
Kox's user avatar
  • 36
2 votes

Understanding uses of on-curve token accounts

createIdempotent will search for the existence of a token account for the given mint and owner, and conduct the necessary creation actions if needed (using initializeAccount3 and any complimentary ...
Joey Meere's user avatar
  • 1,612
1 vote

Creating a new Associated Token Account is 10 times more expensive than expected

If you're using @solana/spl-token, you can get the amount required to create a token account using getMinimumBalanceForRentExemptAccount https://github.com/solana-labs/solana-program-library/blob/...
Jon C's user avatar
  • 19.6k
1 vote

How can I invoke the SPL Token program from my program?

Use the anchor_spl crate. This source code uses that crate to accomplish exactly what I believe you're trying to do, hope it helps you: https://github.com/coral-xyz/anchor/blob/master/tests/spl/token-...
HelmetFace's user avatar
  • 1,807
1 vote
Accepted

How do I unfreeze an Account?

Ah I found it. It's ThawAccount instruction. Here are the docs, I found it under FreezeAccount section: https://spl.solana.com/token
Jonas H.'s user avatar
  • 7,219

Only top scored, non community-wiki answers of a minimum length are eligible