skynetcap / solanaj

Solana RPC client written in Java
MIT License
75 stars 36 forks source link

initializeMint InvalidAccountData invalid account data for instruction #60

Open yang19950611 opened 2 weeks ago

yang19950611 commented 2 weeks ago

When I created the token, I got an error message. The error message is as follows:

Program log: Instruction: InitializeMint, Program log: Error: InvalidAccountData, Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1576 of 399850 compute units, Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: invalid account data for instruction

Here is my code: Account mintAccount = new Account(); TransactionInstruction createAccount = SystemProgram.createAccount(payerAccount.getPublicKey(),mintAccount.getPublicKey(), lamports, 338, TokenProgram.PROGRAM_ID); TransactionInstruction initializeMint = TokenProgram.initializeMint(mintAccount.getPublicKey(), 9, contractManage, contractManage);

skynetcap commented 1 week ago

I believe Token Mints should be created with size 82, not 338. See if that works.

yang19950611 commented 1 week ago

I believe Token Mints should be created with size 82, not 338. See if that works.

Thank you very much, I changed it to 82 and solved the problem. May I ask how to calculate this space in Java?