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: ...
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 ...
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/...
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 ...
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.
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 ...
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 ...
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/...
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-...
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
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
associated-token-program × 11associated-token-account × 6
spl-associated-token-account × 5
spl-token-program × 4
spl-token × 3
token × 3
spl × 2
rust × 1
pda × 1
freeze-token-account × 1
token-2022 × 1
anchor-lang × 1