Open GrimLothar opened 2 years ago
+1, it appears as if in the scenario above, where the payer does not have enough SOL, the usual error about not having enough SOL is caught by the try catch block in the following code
After the error is caught, the getAccount will then fail as the account does not actually exist. A better error message would be helpful here.
Any help is much appreciated. Thanks.
Hi, it doesn't only happen when there is no SOL, it is happening to us in certain occasions, i.e., I can't extract the token account from a specific address... from all the others it does... I don't understand why this happens... for now we have fixed it by placing the account directly in the code, but this is not functional. Please help.
var fromTokenAccount;
if(payer.publicKey=="X"){
fromTokenAccount="Y";
console.log(" Forcing Y as fromTokenAccount");
}else{
fromTokenAccount = await splToken.getOrCreateAssociatedTokenAccount(
connection,
payer.publicKey,
TOKEN_pubkey,
fromWallet.publicKey,
false,
splToken.TOKEN_PROGRAM_ID,
TOKEN_pubkey
)
}
+1 here, I have this error too, but I have SOL in the payer wallet So it's the second case, did anyone found another way to handle this?
+1 also, I'm having the same problem. Same conditions as @GonzaloAraujoC .
+1 also have the same error though I'm assuming that rent fees are > 0.002, but it could be @GonzaloAraujoC assumption either. please help with this error. wouldn't want to continue losing SOL tokens whilst trying to mint tokens
+1, i have the same problem.. for me i still have plenty of SOLs. it's happening randomly.
+1, I am having the same problem. I have enough SOL
@GonzaloAraujoC for the specific public key X, the token account might be an auxiliary token account, not the canonical one. You can read up on auxiliary token accounts here: https://stackoverflow.com/questions/70555227/what-is-solana-spl-token-aux-account
Had this issue just fetching the token account. I ended up just switching the function to this:
const accounts = await this.connection.getTokenAccountsByOwner(
//@ts-ignore
this.publicKey,
{ nftMint }
);
const nftTokenAcc = accounts.value[0].pubkey;
+1, I am having the same problem. I have enough SOL
I was able to fix my problem. My issue was I made a mistake in the token address, I was using a wrong address.
Thanks everyone, I've locked this issue for now since there's enough context on the problem. @grimAgent did a good job of describing what's happening -- the error types being thrown aren't as specific as they could be.
I noticed that when calling
getOrCreateAssociatedTokenAccount
,TokenAccountNotFoundError
gets thrown in very different situations. I'm wondering if this can be improved to throw more specific errors?2 specific scenarios that I found is when the
payer
account doesn't have enough SOL, it throws this error And also when the method takes too long, it also throws this method even though the account is created after the fact.