Skip to main content
7 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,487
6 votes
Accepted

Are new SPL tokens typically transferred from a Mint's token account to a user's Associated Token Account?

To answer your main question: no, that's not per se typical. Technically, you could create an ATA for a Mint account, but that comes with some considerations. How SPL Tokens Work Put simply, a Mint ...
Joe C's user avatar
  • 1,086
6 votes
Accepted

How to efficiently transfer NATIVE SOL to a program accepting WRAPPED SOL?

Each transaction will require the wallet to sign the transaction. Rather than three separate transactions, create one transaction with the three instructions. This is the only way to have the user ...
C.OG's user avatar
  • 2,837
6 votes
Accepted

Can I create an ATA of PDA account?

Yes, a PDA can be the authority of a ATA. How are you determining your PDA and ATA on the client-side? Are you overriding the default TOKEN_PROGRAM_ID and ASSOCIATED_TOKEN_PROGRAM_ID? Based on the ...
AMilz's user avatar
  • 1,566
6 votes
Accepted

Why do some token accounts own themselves?

The owner of a token account is any pubkey. If it's possible to provide signatures for that pubkey, then it's a perfectly valid owner for the token account. The token program explicitly allows for ...
Jon C's user avatar
  • 16.1k
5 votes
Accepted

Which program is this: 4MNPdKu9wFMvEeZBMt3Eipfs5ovVWTJb31pEXDJAAxX5?

It's a deployment of the Serum assert-owner program. Google can be surprisingly revealing of unlisted program IDs
trent.sol's user avatar
  • 4,425
5 votes
Accepted

How to create a program that has the authority to mint tokens

Alright finally came up with a solution that worked for me. That is, a solution that Didn't require me to pass in common accounts like system program Allowed me to set the mint account as the mint ...
Mike's user avatar
  • 121
5 votes
Accepted

Determine if a key is an associated token account

A token account can also be a program-derived address of other programs than the associated token program. So being off the curve doesn't tell you enough. For example, a vault program could store ...
Arowana's user avatar
  • 2,273
5 votes
Accepted

What is the difference between a Token Account and an Associated Token Account?

Thanks to Jordan Sexton for helping me out with this on the phone. An 'Associated Token Account' refers to the address. There are two types of addresses: pubkeys and PDAs. Or, visually: Addresses ...
mikemaccana's user avatar
  • 2,140
5 votes
Accepted

Parse transactions in human readable format

Generally speaking, on-chain transactions are just a bunch of serialized bytes, so to parse it you need to have some more context on what programs it's interacting with. For starters, if it's ...
Ahri's user avatar
  • 4,717
3 votes
Accepted

How to create an associated Token Account in anchor, I'm getting the following error: "insufficient account keys for instruction"

This is a shot in the dark, but are you using an old version of the Solana tools by any chance? There may be a mismatch between the validator and the instruction you're creating. Be sure to have at ...
Jon C's user avatar
  • 16.1k
3 votes
Accepted

Since an Associated Token Account for a wallet can be created by anybody, how can we enforce that Token-2022 immutable ownership is performed on ATAs?

Since all associated token accounts (ATAs) are PDAs of the associated token account program (ATA program), only the ATA program can make ATAs and therefore all ATAs will have immutable ownership. So ...
oscarb.sol's user avatar
3 votes
Accepted

What does it mean exactly for token account owners to reassign ownership to another address?

Metaplex docs have a great explanation and diagrams for understanding the relationship between wallets, token accounts, and mints. Recommend looking through this page: https://docs.metaplex.com/...
john's user avatar
  • 7,487
3 votes

Freeze Delegated Account Not working in Anchor program

First there is a conceptual issue, why do you need to freeze the token in the holder wallet while he would be able to unfreeze it as being the one with the delegated_amount? This is because the ...
Arowana's user avatar
  • 2,273
3 votes
Accepted

How to pay/sign an ATA with a different owner?

Taken from the Solana Program Library docs (bottom of this page), an associated token account can be created for a given wallet by anyone. Whether you use Anchor's init annotation or the instruction ...
Joe C's user avatar
  • 1,086
3 votes
Accepted

How to get Mint Address of of SPL token using associated token account?

import {getAccount} from "@solana/spl-token" const tokenAccount = await getAccount(connection, tokenAccountAddress) console.log(tokenAccount.mint.toBase58()) https://solana-labs.github.io/...
john's user avatar
  • 7,487
3 votes
Accepted

Why is one of the transactions for my token account missing from my wallet in Solana Explorer?

The other three transactions in your screenshot are outgoing (send) transactions. Whereas F3Y transaction is an incoming (receive) transaction. When you interact with the SPL program, it uses the ...
0xShuk's user avatar
  • 1,951
3 votes

Transaction simulation failed: Error processing Instruction 1: invalid account data for instruction

Here is an example of how to build a transaction using @solana/web3.js and @solana/spl-token that will create a token account if it does not already exist and transfer an SPL token in a single ...
john's user avatar
  • 7,487
3 votes
Accepted

Where does a Account of a TokenMint store the maximum capacity it has at the moment?

The total supply of a token mint is tracked by the amount that have been minted. This meaning, when you initially create a mint it will have a supply of 0, but as soon as you mint 5000 (for example) ...
m_callens's user avatar
  • 889
3 votes
Accepted

SPL token account creation and airdrop

You can use the function getOrCreateAssociatedTokenAccount from web3js to get the TokenAccount and create it if it does not exist. If you already have a claim transaction you can also add another ...
Jonas H.'s user avatar
  • 5,787
3 votes
Accepted

For recent created Liquidity pools on Raydium, getTokenAccountBalance returns an error

I'd assume this is due to one of two issues: It takes RPC providers a little bit of time after account creation to index new accounts. You can check if this is the problem for you by using your ...
Ahri's user avatar
  • 4,717
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,086
2 votes
Accepted

Why don't wallets auto-create an associated token account if one doesn't exist?

Phantom and Sollet are calling the assert-owner program by Serum before creating an ATA. This program is only deployed on mainnet. It is not available on testnet/devnet. This is why we can't send ...
itsfarseen's user avatar
2 votes

Why don't wallets auto-create an associated token account if one doesn't exist?

creating a token account costs sol, so if you want your transaction to create an account and pay for it you need to specify --allow-unfunded-recipient in your transaction.
Jonas H.'s user avatar
  • 5,787
2 votes
Accepted

Can I withdraw excess SOL from an associated token account?

Yes, when closing an associated token account all SOL will be withdrawn to a destination account you specify yourself. There is no way to decrease the SOL amount without closing the account.
Omega's user avatar
  • 761
2 votes

How to create a program that has the authority to mint tokens

Try this: // Instruction: Create Mint Account for Airdrop #[derive(Accounts)] pub struct CreateAirdrop<'info> { ... #[account( init, payer = signer, mint::...
Joe C's user avatar
  • 1,086
2 votes

Fee payer query

As mentioned in another answer, it is possible. If the traget is the payer, it has to be a signer as well. Here's an example on how it could look like with Anchor: #[derive(Accounts)] pub struct ...
AllBlooming's user avatar
  • 2,269
2 votes
Accepted

Fee payer query

It would only be possible to take the token account creation fee from the target of the account if the target also signed the transaction.
Henry E's user avatar
  • 3,050
2 votes

TokenAccountNotFoundError after calling getOrCreateAssociatedTokenAccount

it is possible the TokenAccount is in the process of creation, and you should wait for confirmed commitment. From the solana official docs... For processing many dependent transactions in series, it'...
Concise Labs's user avatar
  • 1,376
2 votes

Error Creating AssociatedTokenAccount when the signer/funder is one of the seeds. Any way around this?

The fourth account provided must be the mint, and not the funder. So instead, you should do: List<AccountMeta> metas= new ArrayList<>(); metas.add(new AccountMeta(funder,...
Jon C's user avatar
  • 16.1k

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