2

I am using the below in an endpoint to create a candy machine. Currently getting an incorrect account owner following the guide provided here https://docs.metaplex.com/programs/candy-machine/managing-candy-machines , when I use the generatesigner to use as a keypair it says it needs sol to mint, but the guides use this, opposed to a wallet keypair which I switched out in my example. Thanks for any help. enter image description here

  
  
    try {
      let QUICKNODE_RPC = "https://api.devnet.solana.com"
  
      const umi = createUmi(QUICKNODE_RPC).use(mplCandyMachine()).use(mplTokenMetadata());
      const numberOfItems = 12;
      // console.log("umi", umi)
  
      // Create the Collection NFT.
  
      const keypair = umi.eddsa.createKeypairFromSecretKey(new Uint8Array(secret));
      const umiSigner = createSignerFromKeypair(umi, keypair);
      umi.use(signerIdentity(umiSigner));
  
  
  
      const collectionMint = generateSigner(umi);

      await createNft(umi, {
        mint: collectionMint,
        authority: umiSigner,
        name: "Rowdy Knights Club",
        uri: "assets/collection.json",
        sellerFeeBasisPoints: percentAmount(9.99, 2), // 9.99%
        isCollection: true,
      }).sendAndConfirm(umi);
  
  
      // Create the Candy Machine.
      const candyMachineKeypair = generateSigner(umi);
  
      const instruction = await create(umi, {
        candyMachine: candyMachineKeypair,
        collectionUpdateAuthority: umi.identity,
        collectionMint: collectionMint.publicKey,
        tokenStandard: TokenStandard.ProgrammableNonFungible,
        itemsAvailable: 3,
        sellerFeeBasisPoints: percentAmount(10, 2),
        creators: [
          {
            address: umi.identity.publicKey,
            verified: true,
            percentageShare: 100,
          },
        ],
        symbol: 'Rowdy',
        configLineSettings: some({
          prefixName: '',
          nameLength: 32,
          prefixUri: '',
          uriLength: 200,
          isSequential: false,
        }),
      });
  
  
      await transactionBuilder().add(setComputeUnitLimit(umi, { units: 800_000 })).add(instruction).sendAndConfirm(umi);

...
0

1 Answer 1

0

hey I was also facing the same issue, check the below code

const { createUmi } = require("@metaplex-foundation/umi-bundle-defaults");
const {
  mplCandyMachine,
  create,
  getMplCandyGuardErrorFromCode,
} = require("@metaplex-foundation/mpl-candy-machine");
const {
  createNft,
  TokenStandard,
} = require("@metaplex-foundation/mpl-token-metadata");
const {
  generateSigner,
  percentAmount,
  keypairIdentity,
  some,
} = require("@metaplex-foundation/umi");
const bs58 = require("bs58");

const umi = createUmi(
  "https://api.devnet.solana.com",
).use(mplCandyMachine());

const keypair = umi.eddsa.createKeypairFromSecretKey(
  bs58.decode(
    "YOUR PRIVATE KEY"
  )
);
// const keypairSigner
// Use the RPC endpoint of your choice.

umi.use(keypairIdentity(keypair));

const getFeeForMessage = async (message) => {
  let body = JSON.stringify({
    id: 1,
    jsonrpc: "2.0",
    method: "getFeeForMessage",
    params: [
      message,
      {
        commitment: "processed",
      },
    ],
  });

  let res = await fetch(
    "rpc",
    {
      method: "POST",
      body,
      headers: {
        "Content-Type": "application/json",
      },
    }
  );

  console.log(res.json().then((data) => console.log(data)));
};

async function create_cm() {
  const collectionUpdateAuthority = generateSigner(umi);
  const collectionMint = generateSigner(umi);

  let collection = 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);

  const candyMachine = generateSigner(umi);

  console.log("Accounts")
  console.log(collectionMint.publicKey);
  console.log(collectionUpdateAuthority.publicKey);
  console.log(candyMachine.publicKey);
   

  let nft = await create(umi, {
    candyMachine,
    collectionMint: collectionMint.publicKey,
    collectionUpdateAuthority,
    tokenStandard: TokenStandard.NonFungible,
    sellerFeeBasisPoints: percentAmount(9.99, 2), // 9.99%
    itemsAvailable: 100,
    creators: [
      {
        address: umi.identity.publicKey,
        verified: true,
        percentageShare: 100,
      },
    ],
    configLineSettings: some({
      prefixName: "",
      nameLength: 32,
      prefixUri: "",
      uriLength: 200,
      isSequential: true,
    }),
  });

  let tx = await nft.buildWithLatestBlockhash(umi, {
    commitment: "finalized",
  });

  console.log(tx.message);

  console.log(await nft.sendAndConfirm(umi));
}

create_cm();

The above code is working- also make sure your wallet has enough SOL for the transaction - you can get some devnet sol from faucet.solana.com

1
  • This only worked after I changed const collectionUpdateAuthority = generateSigner(umi); to const collectionUpdateAuthority = keypairSigner.publicKey; where const keypairSigner = createSignerFromKeypair(umi, keypair);
    – localhost
    Commented Mar 28 at 2:31

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.