anchor
anchor copied to clipboard
createAssociatedTokenAccount function seems broken
When initializing token accounts in the test folder ( localnet) , an error pops up saying custom program error: 0x0
I have narrowed it down to this particular token account.. When I remove it, creating the other token accounts work...
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!!
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
Alr did.. Still having the same error!
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.
Oh. Um, I'm currently testing on the local net and have airdropped enough sol to the fundraiser account . Like so,
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 :)
Have you tried deleting the id.json and creating a new one or are you not using it at all?
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).
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.