I'm having trouble minting an NFT using @metaplex-foundation/[email protected]. Whenever I try to do so, I get the following error: AnchorError caused by account: candy_guard. Error Code: AccountOwnedByWrongProgram.
Here's the code I'm using:
const mint = async () => {
if (!wallet?.connected || !candyMachine) {
return;
}
const umi = createUmi(SOLANA_RPC_ENDPOINT)
.use(walletAdapterIdentity(wallet))
.use(mplCandyMachine());
const nftMint = generateSigner(umi);
await transactionBuilder()
.add(setComputeUnitLimit(umi, { units: 1_000_000 }))
.add(
mintV2(umi, {
candyMachine: candyMachine.publicKey,
nftMint,
collectionMint: candyMachine.collectionMint,
collectionUpdateAuthority: candyMachine.authority,
candyGuard: candyMachine.mintAuthority,
mintArgs: {
mintLimit: some({ id: 1 })
}
})
)
.sendAndConfirm(umi);
};
This is the error message that I'm receiving:
Uncaught (in promise) ProgramErrorNotRecognizedError: The program [mplCandyGuard] at address [Guard1JwRhJkVH6XZhzoYxeBVQe872VH6QggF4BWmS9g] raised an error that is not recognized by the programs registered on the SDK. Please check the underlying program error below for more details.
Source: Program > mplCandyGuard [Guard1JwRhJkVH6XZhzoYxeBVQe872VH6QggF4BWmS9g]
Caused By: Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 1: custom program error: 0xbbf
Program Logs:
| Program ComputeBudget111111111111111111111111111111 invoke [1]
| Program ComputeBudget111111111111111111111111111111 success
| Program Guard1JwRhJkVH6XZhzoYxeBVQe872VH6QggF4BWmS9g invoke [1]
| Program log: Instruction: MintV2
| Program log: AnchorError caused by account: candy_guard. Error Code: AccountOwnedByWrongProgram. Error Number: 3007. Error Message: The given account is owned by a different program than expected.
| Program log: Left:
| Program log: 11111111111111111111111111111111
| Program log: Right:
| Program log: Guard1JwRhJkVH6XZhzoYxeBVQe872VH6QggF4BWmS9g
| Program Guard1JwRhJkVH6XZhzoYxeBVQe872VH6QggF4BWmS9g consumed 10260 of 1000000 compute units
| Program Guard1JwRhJkVH6XZhzoYxeBVQe872VH6QggF4BWmS9g failed: custom program error: 0xbbf
at Object.resolveError (createDefaultProgramRepository.mjs:84:1)
at Object.sendTransaction (createWeb3JsRpc.mjs:158:1)
at async TransactionBuilder.sendAndConfirm (TransactionBuilder.mjs:209:1)
at async mint (cmProvider.tsx:84:19)
at async handleMint (index.tsx:24:17)
Here are the dependencies:
"@metaplex-foundation/mpl-candy-machine": "^6.0.0",
"@metaplex-foundation/umi": "^0.8.10",
"@metaplex-foundation/umi-bundle-defaults": "^0.8.10",
"@metaplex-foundation/umi-signer-wallet-adapters": "^0.8.10",
"@solana/spl-token": "^0.3.8",
"@solana/wallet-adapter-base": "^0.9.22",
"@solana/wallet-adapter-react": "^0.15.32",
"@solana/wallet-adapter-react-ui": "^0.9.31",
"@solana/wallet-adapter-wallets": "^0.19.16",
"@solana/web3.js": "^1.76.0"
The Candy machine ID is Ao9bam2dURrcbapnRg6kseAeAeaiCMnJGHncdnRCTSQ.