anchor icon indicating copy to clipboard operation
anchor copied to clipboard

createAssociatedTokenAccount function seems broken

Open bubu59 opened this issue 2 years ago • 7 comments

When initializing token accounts in the test folder ( localnet) , an error pops up saying custom program error: 0x0 image

I have narrowed it down to this particular token account.. When I remove it, creating the other token accounts work... image

I have checked the discord for some answers regarding the error message but I'm not init the fundraiser_token_account as seen in the image above. I'm not really not sure why this is so since it has never happened before this.. Any advice would be greatly appreciated!!

bubu59 avatar Aug 27 '22 16:08 bubu59

It seems fundraiser is expected to create the token account but It does not have enough SOL to pay for rent, Consider doing an airdrop to fundraiser

chinepun avatar Aug 28 '22 00:08 chinepun

Alr did.. Still having the same error! image

bubu59 avatar Aug 28 '22 08:08 bubu59

I've had a similar issue, 0x0 too, what I did is renamed ./.config/solana/id.json to id_whatever.json and generated a new keypair - airdropped a few SOL and voila, the problem was that even though you generate a new keypair each time, the token account was already created somehow, and it won't create it again.

djordjevucinic avatar Aug 28 '22 16:08 djordjevucinic

Oh. Um, I'm currently testing on the local net and have airdropped enough sol to the fundraiser account . Like so, image

bubu59 avatar Aug 29 '22 14:08 bubu59

I have noticed that airdropping SOL to an Account in the local net may not always be successful, I would suggest checking the balance of the account after the airdrop. If there is no SOL after the airdrop, I suggest sending SOL from your anchor provider wallet as it has a starting balance of 500 SOL when testing on the local net. Send SOL from the wallet and check the balance of the fundraiser account, this should work, and hence you will have enough SOL to cover for creating a token account :)

chinepun avatar Aug 29 '22 17:08 chinepun

Have you tried deleting the id.json and creating a new one or are you not using it at all?

djordjevucinic avatar Aug 29 '22 20:08 djordjevucinic

Recommend asking on https://solana.stackexchange.com/ and closing this issue as this appears to not be an issue with anchor itself but the solana runtime or how you're using anchor (e.g. not enough solana in the payer account).

Henry-E avatar Aug 29 '22 20:08 Henry-E

The problem is you're trying to create a token account that already exists but as previous comment suggested, this is not a problem with Anchor and createAssociatedTokenAccount function doesn't even come from Anchor.

acheroncrypto avatar Nov 01 '23 09:11 acheroncrypto