Cant create CandyMachine using umi
xuxianjin-dev opened this issue · comments
I tried to follow the guide in Metaplex to create a CandyMachine using umi.
import { Keypair } from "@solana/web3.js";
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults'
import { publicKey, some, generateSigner, percentAmount, keypairIdentity, createSignerFromKeypair } from "@metaplex-foundation/umi";
import {
fetchCandyMachine,
fetchCandyGuard,
mplCandyMachine,
create,
setCandyMachineAuthority,
setCandyGuardAuthority,
} from '@metaplex-foundation/mpl-candy-machine'
// Use the RPC endpoint of your choice.
import {
createNft,
TokenStandard,
} from '@metaplex-foundation/mpl-token-metadata'
async function manageCandyMachine() {
const umi = createUmi('https://api.devnet.solana.com').use(mplCandyMachine())
// Create the Collection NFT.
const collectionUpdateAuthority = generateSigner(umi)
const collectionMint = generateSigner(umi)
const myKeypair = umi.eddsa.createKeypairFromSecretKey(new Uint8Array([15,96,246,96,168,118,204,153,41,122,14,70,62,175,75,122,122,10,202,172,60,76,153,241,33,130,7,194,51,240,101,221,168,191,211,242,139,189,173,204,59,2,253,72,101,253,176,40,31,52,98,56,62,115,191,231,79,53,241,119,160,252,8,129]));
const myKeypairSigner = createSignerFromKeypair(umi, myKeypair);
umi.use(keypairIdentity(myKeypairSigner));
await createNft(umi, {
mint: collectionMint,
authority: collectionUpdateAuthority,
name: 'My Collection NFT',
uri: 'https://example.com/path/to/some/json/metadata.json',
sellerFeeBasisPoints: percentAmount(9.99, 2), // 9.99%
isCollection: true,
}).sendAndConfirm(umi)
console.log(umi.identity.publicKey);
// Create the Candy Machine.
const candyMachine = generateSigner(umi);
const creatorA = generateSigner(umi).publicKey;
await(await create(umi, {
candyMachine,
collectionMint: collectionMint.publicKey,
collectionUpdateAuthority,
tokenStandard: TokenStandard.NonFungible,
sellerFeeBasisPoints: percentAmount(9.99, 2), // 9.99%
itemsAvailable: 5,
creators: [
{
address: umi.identity.publicKey,
verified: true,
percentageShare: 100,
},
],
configLineSettings: some({
prefixName: '',
nameLength: 32,
prefixUri: '',
uriLength: 200,
isSequential: false,
}),
})).sendAndConfirm(umi)
const candyMachinePublicKey = candyMachine.publicKey
console.log('pub key: ' + candyMachinePublicKey)
// // Fetch the Candy Machine.
const cm = await fetchCandyMachine(umi, candyMachinePublicKey)
const candyGuard = await fetchCandyGuard(umi, cm.mintAuthority)
console.log(cm.publicKey) // The public key of the Candy Machine account.
console.log(cm.mintAuthority) // The mint authority of the Candy Machine which, in most cases, is the Candy Guard address.
console.log(cm.data.itemsAvailable) // Total number of NFTs available.
console.log(cm.itemsRedeemed) // Number of NFTs minted.
}
manageCandyMachine()
ts-node createCandyMachine.ts
E:\Study\Try\mintcnft\node_modules\@metaplex-foundation\umi-program-repository\src\createDefaultProgramRepository.ts:136
return resolvedError ?? new ProgramErrorNotRecognizedError(program, error);
^
ProgramErrorNotRecognizedError: The program [mplCandyMachineCore] at address [CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR] 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 > mplCandyMachineCore [CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR]
Caused By: Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 1: custom program error: 0x39
Program Logs:
| Program 11111111111111111111111111111111 invoke [1]
| Program 11111111111111111111111111111111 success
| Program CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR invoke [1]
| Program log: Instruction: InitializeV2
| Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [2]
| Program log: IX: Delegate
| Program log: Incorrect account owner
| Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 8136 of 777967 compute units
| Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x39
| Program CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR consumed 30019 of 799850 compute units
| Program CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR failed: custom program error: 0x39
at Object.resolveError (E:\Study\Try\mintcnft\node_modules\@metaplex-foundation\umi-program-repository\src\createDefaultProgramRepository.ts:136:29)
at Object.sendTransaction (E:\Study\Try\mintcnft\node_modules\@metaplex-foundation\umi-rpc-web3js\src\createWeb3JsRpc.ts:335:42)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async TransactionBuilder.sendAndConfirm (E:\Study\Try\mintcnft\node_modules\@metaplex-foundation\umi\src\TransactionBuilder.ts:359:23)
at async manageCandyMachine (E:\Study\Try\mintcnft\createCandyMachine.ts:46:3) {
source: 'program',
sourceDetails: 'mplCandyMachineCore [CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR]',
cause: SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 1: custom program error: 0x39
at Connection.sendEncodedTransaction (E:\Study\Try\mintcnft\node_modules\@solana\web3.js\src\connection.ts:5921:13)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Connection.sendRawTransaction (E:\Study\Try\mintcnft\node_modules\@solana\web3.js\src\connection.ts:5880:20)
at async Object.sendTransaction (E:\Study\Try\mintcnft\node_modules\@metaplex-foundation\umi-rpc-web3js\src\createWeb3JsRpc.ts:327:25)
at async TransactionBuilder.sendAndConfirm (E:\Study\Try\mintcnft\node_modules\@metaplex-foundation\umi\src\TransactionBuilder.ts:359:23)
at async manageCandyMachine (E:\Study\Try\mintcnft\createCandyMachine.ts:46:3) {
logs: [
'Program 11111111111111111111111111111111 invoke [1]',
'Program 11111111111111111111111111111111 success',
'Program CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR invoke [1]',
'Program log: Instruction: InitializeV2',
'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [2]',
'Program log: IX: Delegate',
'Program log: Incorrect account owner',
'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 8136 of 777967 compute units',
'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x39',
'Program CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR consumed 30019 of 799850 compute units',
'Program CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR failed: custom program error: 0x39'
]
},
program: {
name: 'mplCandyMachineCore',
publicKey: 'CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR',
getErrorFromCode: [Function: getErrorFromCode],
getErrorFromName: [Function: getErrorFromName],
isOnCluster: [Function: isOnCluster]
},
logs: [
'Program 11111111111111111111111111111111 invoke [1]',
'Program 11111111111111111111111111111111 success',
'Program CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR invoke [1]',
'Program log: Instruction: InitializeV2',
'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [2]',
'Program log: IX: Delegate',
'Program log: Incorrect account owner',
'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 8136 of 777967 compute units',
'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x39',
'Program CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR consumed 30019 of 799850 compute units',
'Program CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR failed: custom program error: 0x39'
]
}
I am not sure why this error occurs. And when I tried to get the candymachine account information with given candymachine id, I encountered wrong discriminator error. Does someone have experience with resolving this kind of issue?
Any updates on this? Experiencing the same issue...