2

I have recently begun getting the below error when running the createMint instruction from @solana/spl-token. To my knowledge, I have not changed any code or dependencies that would affect this.

Example Code

import { PublicKey, Connection, Keypair } from "@solana/web3.js";
import * as spl from "@solana/spl-token";

export async function generateMint(
  // I have confirmed that the authority exists and has sufficient funds (1 SOL)
  authority: Keypair,
  connection: Connection
): Promise<Keypair> {
  const mint: Keypair = Keypair.generate();
  try {
    await spl.createMint(
      connection,
      authority,
      authority.publicKey,
      authority.publicKey,
      9,
      mint
    );

  } catch (e) {
    console.trace(e)
    throw e
  }

  return mint;
}

Error

Trace: SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 1: custom program error: 0xc
    at Connection.sendEncodedTransaction (/path/to/node_modules/@solana/web3.js/src/connection.ts:5054:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Connection.sendRawTransaction (/path/to/node_modules/@solana/web3.js/src/connection.ts:5013:20)
    at Connection.sendTransaction (/path/to/node_modules/@solana/web3.js/src/connection.ts:5001:12)
    at sendAndConfirmTransaction (/path/to/node_modules/@solana/web3.js/src/utils/send-and-confirm-transaction.ts:31:21) {
  logs: [
    'Program 11111111111111111111111111111111 invoke [1]',
    'Program 11111111111111111111111111111111 success',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]',
    'Program log: Error: Invalid instruction',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 796 of 1400000 compute units',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: custom program error: 0xc'
  ]
}

Context

  • OS Ubuntu 20.04.4 LTS (WSL 2)
  • @project-serum/anchor: 0.25.0
  • @solana/spl-token: 0.3.5
  • invoking command: anchor test (== yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts)
4
  • I can't say specifically why this fails but this is the preferred way of creating an spl token(according to the spl docs): ``` let mint = await spl.createMint( connection, authority, authority.publicKey, authority.publicKey, 9 ); return mint; ```
    – Ademola
    Oct 22, 2022 at 10:39
  • I just tested my code sample for creating a mint using the JS library with no issues. What Solana network cluster are you connecting to?
    – nickfrosty
    Oct 22, 2022 at 14:26
  • I'm using localnet, running tests for my program using anchor test
    – austinmilt
    Oct 22, 2022 at 16:11
  • That could be the issue. The version of the Token program could be different between your localnet and the devnet/production version. Try running your same code on devnet. There are currently changes in the works for the SPL token program and token swap program
    – nickfrosty
    Oct 23, 2022 at 12:50

1 Answer 1

0

Downgrading @solana/spl-token to 0.2.0 worked. I guess anchor is not up to date with solana...?

1
  • This is a workaround, not an answer. Jan 27, 2023 at 14:02

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.