metaplex-foundation / sugar

Candy Machine Rust CLI.
Apache License 2.0
198 stars 112 forks source link

ProgramNotRecognizedError: The provided program name [mplCandyGuard] is not recognized in the [devnet] cluster #444

Closed joydmukherjee closed 1 year ago

joydmukherjee commented 1 year ago

Hi..I am trying to mint NFTs from a candy machine v3 using the umi library as shown in this https://docs.metaplex.com/programs/candy-machine/minting . I am using the following code - `import React from 'react' import { Metaplex, walletAdapterIdentity } from "@metaplex-foundation/js"; import { useConnection, useWallet } from "@solana/wallet-adapter-react"; import { useMemo, useState } from "react"; import { some, generateSigner, transactionBuilder, } from "@metaplex-foundation/umi"; import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"; import {mintV2} from "@metaplex-foundation/mpl-candy-machine"; import { setComputeUnitLimit } from "@metaplex-foundation/mpl-essentials"; import { Connection, } from "@solana/web3.js";

const MintNFT = () => { const { publicKey, wallet } = useWallet(); const [nft, setNft] = useState(null); const umi = useMemo( () => createUmi(process.env.NEXT_PUBLIC_SOLANA_RPC_HOST), [] ); const connection = useMemo( () => new Connection(process.env.NEXT_PUBLIC_SOLANA_RPC_HOST, "confirmed"), [] ); const candyMachineAddress = new PublicKey( process.env.NEXT_PUBLIC_CANDY_MACHINE_ID ); const metaplex = useMemo( () => Metaplex.make(connection).use(walletAdapterIdentity(wallet)), [connection, wallet] ); let candyMachine; let walletBalance; const onClick = async () => { // Here the actual mint happens. Depending on the guards that you are using you have to run some pre validation beforehand // Read more: https://docs.metaplex.com/programs/candy-machine/minting#minting-with-pre-validation // read candy machine state from chain candyMachine = await metaplex .candyMachines() .findByAddress({ address: candyMachineAddress }); console.log(candyMachine); await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 800_000 })) .add( mintV2(umi, { candyMachine: candyMachine.address, publicKey, collectionMint: candyMachine.collectionMintAddress, collectionUpdateAuthority: candyMachine.authorityAddress, mintArgs: { mintLimit: some({ id: 1 }), solPayment: some({ destination: candyMachine.authorityAddress }), }, }) ) .sendAndConfirm(umi); };

return (

Here we mint the NFT
{nft && (

{nft.name}

The downloaded illustration of the provided NFT address.
)}

); }

export default MintNFT`

but on clicking the Mint NFT button I am getting the following error - caught (in promise) ProgramNotRecognizedError: The provided program name [mplCandyGuard] is not recognized in the [devnet] cluster. Did you forget to register this program? If so, you may use "context.programs.add(myProgram)" to fix this.

Source: SDK Can somebody please suggest what is wrong ? I am using sugar-cli v2.1.1

febo commented 1 year ago

This seems to the a Umi related issue, not Sugar. Did you try asking in Discord?

samuelvanderwaal commented 1 year ago

Closed for lack of activity, and appears to be related to Umi library, not Sugar.