6

I create an automated deployment script that will mint 2 million SPL tokens to an address, the mint is owned by the program PDA as shown in Solana explorer:

1

Bellow is the last step in the deployment script:

export async function mint2e6Tokens(provider: anchor.AnchorProvider, tokenAccount: PublicKey, mint: PublicKey): Promise<void> {
  // get the token account could be PDA
  const programKeypair = await createKeypairFromFile(PROGRAM_KEYPAIR_PATH);
  /** Load from PDA */
  let mint_tokens_tx = new Transaction().add(
    createMintToInstruction(
      mint,
      tokenAccount,
      programKeypair.publicKey, // -> I DOUBLE CHECKED, THIS IS 6Z24B3qCrWfWvDo1f2HgxmnBSGhqQes1sHobqMtMxfbP
      2e6,
      [],
      TOKEN_PROGRAM_ID
    )
  );
  // We sign with our programId instead of the wallet because this is a PDA
  // Program Derived Adress
  await provider.sendAndConfirm(mint_tokens_tx, [programKeypair]);
}

When I run in LocalNet, it works:

Migrating to LocalNet...
RUNNING CUSTOM SCRIPT ====>>> 
Payper: EsgJ9ihTEZskWyWpMMPuGVisy5ay76YWgetgTLb3jRmj
Using program 6Z24B3qCrWfWvDo1f2HgxmnBSGhqQes1sHobqMtMxfbP
Program: 6Z24B3qCrWfWvDo1f2HgxmnBSGhqQes1sHobqMtMxfbP
Mint: AVPgrT1y6ZfjGWPyLCWEPZdogRgmEMbrdRbcHNSfAPzF
Campaign: FcAmyEgZsXUKLB6hKufDmLuSBzMzVtPmRPm7vZLStK4U
31999500

However when I switch to DevNet, it always give me error

Migrating to DevNet...
RUNNING CUSTOM SCRIPT ====>>> 
Payper: EsgJ9ihTEZskWyWpMMPuGVisy5ay76YWgetgTLb3jRmj
Using program 6Z24B3qCrWfWvDo1f2HgxmnBSGhqQes1sHobqMtMxfbP
Program: 6Z24B3qCrWfWvDo1f2HgxmnBSGhqQes1sHobqMtMxfbP
Mint: AVPgrT1y6ZfjGWPyLCWEPZdogRgmEMbrdRbcHNSfAPzF
Campaign: FcAmyEgZsXUKLB6hKufDmLuSBzMzVtPmRPm7vZLStK4U
SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x3
    at Connection.sendEncodedTransaction (/code/beens/node_modules/@solana/web3.js/src/connection.ts:4248:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Connection.sendRawTransaction (/code/beens/node_modules/@solana/web3.js/src/connection.ts:4210:20)
    at async sendAndConfirmRawTransaction (/code/beens/node_modules/@project-serum/anchor/src/provider.ts:288:21)
    at async AnchorProvider.sendAndConfirm (/code/beens/node_modules/@project-serum/anchor/src/provider.ts:148:14) {
  logs: [
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]',
    'Program log: Instruction: MintTo',
    'Program log: Error: Account not associated with this Mint',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2809 of 200000 compute units',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: custom program error: 0x3'
  ]
}

Why the authority is right, but Solana complains that Error: Account not associated with this Mint?

1
  • 1
    Is the tokenAccount created for the mint in devnet? probably the issue is tokenAccount not having the same mint or not being initialized
    – Sushi
    Commented Sep 14, 2022 at 4:33

1 Answer 1

1

Thank you for the response. I figured out that the right Anchor version is very crucial to move from localhost -> devnet -> testnet -> mainnet. Check the version release note, sometime the newest version will not work with testnet or mainnet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.