1

I have the following function, where I want to create a fungible token using UMI.

const metadata = {
    name: "Solana Gold",
    symbol: "GOLDSOL",
    uri: "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json",
};

const mint = generateSigner(umi);

async function createMetadataDetails() {
    await createV1(umi, {
        mint,
        authority: umi.identity,
        name: metadata.name,
        symbol: metadata.symbol,
        uri: metadata.uri,
        sellerFeeBasisPoints: percentAmount(0),
        decimals: 9,
        tokenStandard: TokenStandard.Fungible,
    }).sendAndConfirm(umi)
}

async function mintToken() {
    await mintV1(umi, {
        mint: mint.publicKey,
        authority: umi.identity,
        amount: 10_000,
        tokenOwner: umi.identity.publicKey,
        tokenStandard: TokenStandard.Fungible,
    }).sendAndConfirm(umi)
}

Currently It fails when calling mintV1. Error logs below.

      at processTicksAndRejections (node:internal/process/task_queues:95:5) {
    logs: [
      'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]',
      'Program log: IX: Mint',
      'Program log: Incorrect account owner',
      'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 8790 of 200000 compute units',
      'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x39'
    ]
  },
  program: {
    name: 'mplTokenMetadata',
    publicKey: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
    getErrorFromCode: [Function: getErrorFromCode],
    getErrorFromName: [Function: getErrorFromName],
    isOnCluster: [Function: isOnCluster]
  },
  logs: [
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]',
    'Program log: IX: Mint',
    'Program log: Incorrect account owner',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 8790 of 200000 compute units',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x39'
  ],
  code: 57
}

developer docs link

I think the createV1 isn't creating the mint account as expected.

3 Answers 3

1

As I told you in my previous answer's comments, I found this function (createAndMint), on Metaplex GitHub repo, that might be what you were looking for... You can set the supply with it, and it happens that you don't need to use any of the other functions, just this one; you still need the metadata, of course.

The code would look like this:

const metadata = {
    name: "Solana Gold",
    symbol: "GOLDSOL",
    uri: "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json",
};

const mint = generateSigner(umi);

createAndMint(umi, {
    mint,
    authority: umi.identity,
    name: metadata.name,
    symbol: metadata.symbol,
    uri: metadata.uri,
    sellerFeeBasisPoints: percentAmount(0),
    decimals: 9,
    amount: 10_000,
    tokenOwner: umi.identity.publicKey,
    tokenStandard: TokenStandard.Fungible,
    }).sendAndConfirm(umi).then(() => {
    console.log("Some success message like: 0.00001 GOLDSOL (", mint.publicKey, ") minted");
});

I hope this helps

0

I believe you are having the same issue as myself few hours ago. When I tried minting a token I created I was get

ProgramNotRecognizedError: The provided program name [splAssociatedToken] is not recognized in the [devnet] cluster.

I solved this by installing Metaplex CandyShop plugin npm install @metaplex-foundation/mpl-candy-machine then proceed to adding the plugin to my umi instance

import { mplCandyMachine } from "@metaplex-foundation/mpl-candy-machine";

umi.use(mplCandyMachine())
2
  • I believe you were minting a non-fungible collection that required the use of the candy machine. I am trying to create fungible tokens and add metadata using the mplTokeneMetadata program.
    – Jimii
    Sep 28 at 9:44
  • @Jimii I was actually minting a fungible token
    – Tochukwu
    Sep 29 at 10:37
0

I managed to make it work using this createFungible function:

createMetadataDetails().then(() => {
  createFungible(umi, {
    mint,
    authority: umi.identity,
    name: metadata.name,
    symbol: metadata.symbol,
    uri: metadata.uri,
    sellerFeeBasisPoints: percentAmount(0),
    decimals: 9,
  }).sendAndConfirm(umi).then(() => {
      mintToken();
});

});

8
  • Can you try setting the supply using the method you used.
    – Jimii
    Oct 16 at 7:09
  • @Jimii, the supply is set in the mintToken() function. You can mint whatever amount you need.
    – jmontes
    Oct 17 at 8:18
  • @Jimii, kindly notice that I'm reusing the functions you already defined. I'm not replacing them
    – jmontes
    Oct 17 at 9:34
  • notice that I also included that using the mintToken() and createMetadataDetails() functions are giving me an error. while using createFungible does work, it does not allow me to set the supply for my token.
    – Jimii
    Oct 17 at 9:40
  • Yes, I get the same error if I just use those two functions mintToken() and createMetadataDetails(). But if I combine them with createFungible (as shown in my sniped) it works fine. You can still use mintV1 (inside mintToken()) to set the amount of tokens to mint
    – jmontes
    Oct 17 at 10:20

Your Answer

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

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