Giter VIP home page Giter VIP logo

solana-candy-factory's Introduction

Hey, this repo is now completely outdated as it only implements the Candy Machine V1 (which has been desactivated by Metaplex)! Feel free to send a PR for supporting CM2 OR use the example app in the Metaplex official repo


Solana NFT Candy Factory

Read this if you are coming from the Quicknode guide

Currently, this repo has been reworked to represent its new goals. However, we still have some major guides in the ecosystem using the old version as reference. So, I've created a new branch from before the rework if you want to use: https://github.com/kevinfaveri/solana-candy-factory/tree/old_repo

I'm brainstorming a few ideas at IDEAS and PROGRAM IDEAS if you want to collaborate.

NOTE: This repo will prob only work on unix-based environments.

The NFT Candy Factory project is designed to let users fork, customize, and deploy their own candy machine mint app to a custom domain, ultra fast.

A candy machine is an on-chain Solana program for managing fair mint. Fair mints:

  • Start and finish at the same time for everyone.
  • Won't accept your funds if they're out of NFTs to sell.

It builds on top of the the work started at https://github.com/exiled-apes/candy-machine-mint, abstracting away a few things (like having one-command shortcuts in the package.json that instantly setups dev env), improving DX and adding new tools for managing the source files. It also features some other features:

  • Listing of NFTs of the collection
  • A tool for getting the mint hashes
  • A tool for getting the list of holders
  • Multiple mint in the same prompt
  • ReCaptcha support

Techwise, it builds on top of NextJS and TailwindCSS for the frontend (as well as Solana Labs toolchain and Serum Anchor libs for interacting with the Solana network); and Metaplex and Solana clis for deployment on the Solana network.

Getting Set Up

Prerequisites

  • Ensure you have recent versions of both node and yarn installed.

  • Follow the instructions here to install the Solana Command Line Toolkit.

  • Follow the instructions here to install the Metaplex Command Line Utility.

    • Installing the Command Line Package is currently an advanced task that will be simplified eventually.

Advanced Features

ReCaptcha

For adding support for recaptcha just add the NEXT_PUBLIC_RECAPTCHA_KEY (client key) and RECAPTCHA_SECRET (server secret key) keys to your .env file in which the value will be your recaptcha client side key. You can generate them using your Google account: https://www.google.com/recaptcha/about/

If you do not want to use ReCaptcha, then just use a plain button and not the ReCaptcha button component.

Devnnet

In the project root directory, you can run:

  • yarn setup-dev -- Setup development environment: needs solana and metaplex cli installed (it will create a new Solana wallet, drop some sols there, and upload the resources to the devnet Metaplex program, making it ready to test using yarn dev...). This command automatically generates the .env.local file for you with the start date, candy machine addresses, and treasury addresses.

Note: You will still need to generate NFT sources and place in the 'nft-sources' folder. There are a few examples in this repository. They should always start with 0.json and 0.png.

ALERT: Running this command will replace your Solana devwallet generated before at ~/.config/solana/candyfactory-devnet.json as well as all previous environment stuff you had, like your .env.local. It is a nuke solution for resetting development environment. The source scripts are available in the devtools folder in the root of the project. So, if something goes wrong, go into this folder and try running each command a time.

After your Devnnet candy machine has been created feel free to run:

  • yarn dev -- Run NextJS devserver; it features a modal for connecting with wallets; minting of the NFT; success/error messages; and UI countdown based on the candy machine start date.

Mainnet

  • You can't incrementally upload in batches your NFTs. You should do it in one go, always. If you update your batch, you will need to upload it all again. The way to do this then will be to delete the candy machine folder.
  • Don't forget to use the wallet you want to earn the mint value for both metaplex uploading (yarn deploy-mainnet) and in the NFT's creators.address[0] for earning the royaties.
  • You should have all your NFTs ready before deploying. Incremental deploying of NFTs is not supported right now. Feel free to add a PR tho if you find a solution for this

For deploying your collection on the mainnet just run yarn deploy-mainnet and answer the questions as prompted. It will store your wallet key in our path: ~/.config/solana/candyfactory-mainnet.json (if you want to edit that just tweak setup-solana-mainnet.sh). It is the same process as used for the development environment but asking for importing a Wallet PK (that should have enough SOLs and will be the one that will receive the mint value).

After the deployment is over, it will generate all envs that your frontend dApp needs in a file called .env.local.production in the root of the project. These env values should then be added as environment variables where you build your dAapp (if Vercel, you need to add to their ENVIROMENT VARIABLES config section).

Donate

The best way to support me is by following me on https://twitter.com/kevcode_art and https://twitter.com/aiphotos_ (which is the art project that inspired this repository) :)

Others Tools

If you want multisig wallets, you may study https://github.com/GokiProtocol/goki or the https://github.com/project-serum/multisig.

A ton of other useful tools/repos: https://github.com/HashLips/hashlips_art_engine

https://github.com/exiled-apes/candy-machine-mint

https://github.com/InnerMindDAO/MintUI (GUI for the Candy Machine)

https://github.com/theskeletoncrew/treat-toolbox (WebApp for creating collections using a web UI)

https://github.com/samuelvanderwaal/metaboss (CLI with useful tools for Metaplex software)

solana-candy-factory's People

Contributors

fletchertyler914 avatar grmkris avatar kevinfaveri avatar oboxodo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

solana-candy-factory's Issues

update_info

when updating address, update_info resolves address field into the root of the json file, not under the properties

i tryed to remain item counter and price viewer.

\src\utils\candy-machine.ts
import * as anchor from "@project-serum/anchor";

import {
  MintLayout,
  TOKEN_PROGRAM_ID,
  Token,
} from "@solana/spl-token";
import { LAMPORTS_PER_SOL } from "@solana/web3.js";
export const CANDY_MACHINE_PROGRAM = new anchor.web3.PublicKey(
  "cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ"
);

const SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = new anchor.web3.PublicKey(
  "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
);

const TOKEN_METADATA_PROGRAM_ID = new anchor.web3.PublicKey(
  "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
);

export interface CandyMachine {
  id: anchor.web3.PublicKey,
  connection: anchor.web3.Connection;
  program: anchor.Program;
}

interface CandyMachineState {
  candyMachine: CandyMachine;
  itemsAvailable: number;
  itemsRedeemed: number;
  itemsRemaining: number;
  goLiveDate: Date,
  price: number,
}

export const awaitTransactionSignatureConfirmation = async (
  txid: anchor.web3.TransactionSignature,
  timeout: number,
  connection: anchor.web3.Connection,
  commitment: anchor.web3.Commitment = "recent",
  queryStatus = false
): Promise<anchor.web3.SignatureStatus | null | void> => {
  let done = false;
  let status: anchor.web3.SignatureStatus | null | void = {
    slot: 0,
    confirmations: 0,
    err: null,
  };
  let subId = 0;
  status = await new Promise(async (resolve, reject) => {
    setTimeout(() => {
      if (done) {
        return;
      }
      done = true;
      console.log("Rejecting for timeout...");
      reject({ timeout: true });
    }, timeout);
    try {
      subId = connection.onSignature(
        txid,
        (result: any, context: any) => {
          done = true;
          status = {
            err: result.err,
            slot: context.slot,
            confirmations: 0,
          };
          if (result.err) {
            console.log("Rejected via websocket", result.err);
            reject(status);
          } else {
            console.log("Resolved via websocket", result);
            resolve(status);
          }
        },
        commitment
      );
    } catch (e) {
      done = true;
      console.error("WS error in setup", txid, e);
    }
    while (!done && queryStatus) {
      // eslint-disable-next-line no-loop-func
      (async () => {
        try {
          const signatureStatuses = await connection.getSignatureStatuses([
            txid,
          ]);
          status = signatureStatuses && signatureStatuses.value[0];
          if (!done) {
            if (!status) {
              console.log("REST null result for", txid, status);
            } else if (status.err) {
              console.log("REST error for", txid, status);
              done = true;
              reject(status.err);
            } else if (!status.confirmations) {
              console.log("REST no confirmations for", txid, status);
            } else {
              console.log("REST confirmation for", txid, status);
              done = true;
              resolve(status);
            }
          }
        } catch (e) {
          if (!done) {
            console.log("REST connection error: txid", txid, e);
          }
        }
      })();
      await sleep(2000);
    }
  });

  //@ts-ignore
  if (connection._signatureSubscriptions[subId]) {
    connection.removeSignatureListener(subId);
  }
  done = true;
  console.log("Returning status", status);
  return status;
}

/* export */ const createAssociatedTokenAccountInstruction = (
  associatedTokenAddress: anchor.web3.PublicKey,
  payer: anchor.web3.PublicKey,
  walletAddress: anchor.web3.PublicKey,
  splTokenMintAddress: anchor.web3.PublicKey
) => {
  const keys = [
    { pubkey: payer, isSigner: true, isWritable: true },
    { pubkey: associatedTokenAddress, isSigner: false, isWritable: true },
    { pubkey: walletAddress, isSigner: false, isWritable: false },
    { pubkey: splTokenMintAddress, isSigner: false, isWritable: false },
    {
      pubkey: anchor.web3.SystemProgram.programId,
      isSigner: false,
      isWritable: false,
    },
    { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
    {
      pubkey: anchor.web3.SYSVAR_RENT_PUBKEY,
      isSigner: false,
      isWritable: false,
    },
  ];
  return new anchor.web3.TransactionInstruction({
    keys,
    programId: SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID,
    data: Buffer.from([]),
  });
}

export const getCandyMachineState = async (
  anchorWallet: anchor.Wallet,
  candyMachineId: anchor.web3.PublicKey,
  connection: anchor.web3.Connection,
): Promise<CandyMachineState> => {
  const provider = new anchor.Provider(connection, anchorWallet, {
    preflightCommitment: "recent",
  });

  const idl = await anchor.Program.fetchIdl(
    CANDY_MACHINE_PROGRAM,
    provider
  );

  const program = new anchor.Program(idl, CANDY_MACHINE_PROGRAM, provider);
  const candyMachine = {
    id: candyMachineId,
    connection,
    program,
  }
  const state: any = await program.account.candyMachine.fetch(candyMachineId);
  console.log('state.data', state.data);
  const itemsAvailable = state.data.itemsAvailable.toNumber();
  const itemsRedeemed = state.itemsRedeemed.toNumber();
  const itemsRemaining = itemsAvailable - itemsRedeemed;
  const price = state.data.price.toNumber() * 0.000000001;

  let goLiveDate = state.data.goLiveDate.toNumber();
  goLiveDate = new Date(goLiveDate * 1000);

  return {
    candyMachine,
    itemsAvailable,
    itemsRedeemed,
    itemsRemaining,
    goLiveDate,
	price,
  };
}

const getMasterEdition = async (
  mint: anchor.web3.PublicKey
): Promise<anchor.web3.PublicKey> => {
  return (
    await anchor.web3.PublicKey.findProgramAddress(
      [
        Buffer.from("metadata"),
        TOKEN_METADATA_PROGRAM_ID.toBuffer(),
        mint.toBuffer(),
        Buffer.from("edition"),
      ],
      TOKEN_METADATA_PROGRAM_ID
    )
  )[0];
};

const getMetadata = async (
  mint: anchor.web3.PublicKey
): Promise<anchor.web3.PublicKey> => {
  return (
    await anchor.web3.PublicKey.findProgramAddress(
      [
        Buffer.from("metadata"),
        TOKEN_METADATA_PROGRAM_ID.toBuffer(),
        mint.toBuffer(),
      ],
      TOKEN_METADATA_PROGRAM_ID
    )
  )[0];
};

const getTokenWallet = async (
  wallet: anchor.web3.PublicKey,
  mint: anchor.web3.PublicKey
) => {
  return (
    await anchor.web3.PublicKey.findProgramAddress(
      [wallet.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()],
      SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID
    )
  )[0];
};

export const mintOneToken = async (
  candyMachine: CandyMachine,
  config: anchor.web3.PublicKey,
  payer: anchor.web3.PublicKey,
  treasury: anchor.web3.PublicKey,
): Promise<string> => {
  const mint = anchor.web3.Keypair.generate();
  const token = await getTokenWallet(payer, mint.publicKey);
  const { connection, program } = candyMachine;
  const metadata = await getMetadata(mint.publicKey);
  const masterEdition = await getMasterEdition(mint.publicKey);

  const rent = await connection.getMinimumBalanceForRentExemption(
    MintLayout.span
  );

  return await program.rpc.mintNft({
    accounts: {
      config,
      candyMachine: candyMachine.id,
      payer: payer,
      wallet: treasury,
      mint: mint.publicKey,
      metadata,
      masterEdition,
      mintAuthority: payer,
      updateAuthority: payer,
      tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID,
      tokenProgram: TOKEN_PROGRAM_ID,
      systemProgram: anchor.web3.SystemProgram.programId,
      rent: anchor.web3.SYSVAR_RENT_PUBKEY,
      clock: anchor.web3.SYSVAR_CLOCK_PUBKEY,
    },
    signers: [mint],
    instructions: [
      anchor.web3.SystemProgram.createAccount({
        fromPubkey: payer,
        newAccountPubkey: mint.publicKey,
        space: MintLayout.span,
        lamports: rent,
        programId: TOKEN_PROGRAM_ID,
      }),
      Token.createInitMintInstruction(
        TOKEN_PROGRAM_ID,
        mint.publicKey,
        0,
        payer,
        payer
      ),
      createAssociatedTokenAccountInstruction(
        token,
        payer,
        payer,
        mint.publicKey
      ),
      Token.createMintToInstruction(
        TOKEN_PROGRAM_ID,
        mint.publicKey,
        token,
        payer,
        [],
        1
      ),
    ],
  });
}

export const shortenAddress = (address: string, chars = 4): string => {
  return `${address.slice(0, chars)}...${address.slice(-chars)}`;
};

const sleep = (ms: number): Promise<void> => {
  return new Promise((resolve) => setTimeout(resolve, ms));
}`

`
\src\hooks\use-candy-machine.ts

import { useEffect, useState } from "react";
import * as anchor from "@project-serum/anchor";
import { awaitTransactionSignatureConfirmation, CandyMachine, getCandyMachineState, mintOneToken } from "../utils/candy-machine";
import { useWallet } from "@solana/wallet-adapter-react";
import toast from 'react-hot-toast';
import useWalletBalance from "./use-wallet-balance";
import { LAMPORTS_PER_SOL } from "@solana/web3.js";

const treasury = new anchor.web3.PublicKey(
  process.env.NEXT_PUBLIC_TREASURY_ADDRESS!
);

const config = new anchor.web3.PublicKey(
  process.env.NEXT_PUBLIC_CANDY_MACHINE_CONFIG!
);

const candyMachineId = new anchor.web3.PublicKey(
  process.env.NEXT_PUBLIC_CANDY_MACHINE_ID!
);

const rpcHost = process.env.NEXT_PUBLIC_SOLANA_RPC_HOST!;
const connection = new anchor.web3.Connection(rpcHost);

const txTimeout = 30000;

export default function useCandyMachine() {
  const [, setBalance] = useWalletBalance()
  const [candyMachine, setCandyMachine] = useState<CandyMachine>();
  const wallet = useWallet();
  const [isMinting, setIsMinting] = useState(false); // true when user got to press MINT
  const [isSoldOut, setIsSoldOut] = useState(false); // true when items remaining is zero
  const [counter, setCounter] = useState<any>({});
  const [price, setPrice] = useState<number | null>(null);
  const [mintStartDate, setMintStartDate] = useState(new Date(parseInt(process.env.NEXT_PUBLIC_CANDY_START_DATE!, 10)));

  useEffect(() => {
    (async () => {
      if (
        !wallet ||
        !wallet.publicKey ||
        !wallet.signAllTransactions ||
        !wallet.signTransaction
      ) {
        return;
      }

      const anchorWallet = {
        publicKey: wallet.publicKey,
        signAllTransactions: wallet.signAllTransactions,
        signTransaction: wallet.signTransaction,
      } as anchor.Wallet;

      const { candyMachine, goLiveDate, itemsRemaining, itemsAvailable, price } =
        await getCandyMachineState(
          anchorWallet,
          candyMachineId,
          connection
        );

      setIsSoldOut(itemsRemaining === 0);
      setMintStartDate(goLiveDate);
      setCandyMachine(candyMachine);
      setCounter({
        itemsRemaining,
        itemsAvailable
      });
      setPrice(price);
    })();
  }, [wallet, candyMachineId, connection]);

  const onMint = async () => {
    try {
      setIsMinting(true);
      if (wallet.connected && candyMachine?.program && wallet.publicKey) {
        const mintTxId = await mintOneToken(
          candyMachine,
          config,
          wallet.publicKey,
          treasury
        );

        const status = await awaitTransactionSignatureConfirmation(
          mintTxId,
          txTimeout,
          connection,
          "singleGossip",
          false
        );

        if (!status?.err) {
          toast.success("Congratulations! Mint succeeded!")
        } else {
          toast.error("Mint failed! Please try again!")
        }
      }
    } catch (error: any) {
      let message = error.msg || "Minting failed! Please try again!";
      if (!error.msg) {
        if (error.message.indexOf("0x138")) {
        } else if (error.message.indexOf("0x137")) {
          message = `SOLD OUT!`;
        } else if (error.message.indexOf("0x135")) {
          message = `Insufficient funds to mint. Please fund your wallet.`;
        }
      } else {
        if (error.code === 311) {
          message = `SOLD OUT!`;
          setIsSoldOut(true);
        } else if (error.code === 312) {
          message = `Minting period hasn't started yet.`;
        }
      }
      toast.error(message)
    } finally {
      if (wallet?.publicKey) {
        const balance = await connection.getBalance(wallet?.publicKey);
        setBalance(balance / LAMPORTS_PER_SOL);
      }
      setIsMinting(false);
    }
  };


  return { isSoldOut, mintStartDate, isMinting, onMint }
}`

`
\src\pages\mint.tsx

import Head from 'next/head'
import { Navbar } from '../components/Navbar';
import { useState } from "react";
import { Toaster } from 'react-hot-toast';
import { useWallet } from "@solana/wallet-adapter-react";

import {
  shortenAddress,
} from "../utils/candy-machine";
import useCandyMachine from '../hooks/use-candy-machine';
import useWalletBalance from '../hooks/use-wallet-balance';
import Countdown from 'react-countdown';
import { WalletMultiButton } from '@solana/wallet-adapter-react-ui';


const Mint = () => {
  const [balance] = useWalletBalance()
  const [isActive, setIsActive] = useState(false); // true when countdown completes
  const wallet = useWallet();
  const [counter, setCounter] = useState<any>({});
  const [price, setPrice] = useState<number | null>(null);
  const { isSoldOut, mintStartDate, isMinting, onMint } = useCandyMachine()

  return (
    <main className="">
      <Toaster />
      <Head>
        <title>Solana Candy Machine</title>
        <meta name="description" content="Solana Candy Machine is an open-source project using NextJS, 
          Metaplex protocol which serve as an example app for a NFT candy machine app." />
        <link rel="icon" href="/favicon.ico" />
      </Head>
	  <Navbar />
	  <div>
          <br />
	  {!!counter && (
        <>
          Items available: {counter.itemsRemaining} / {counter.itemsAvailable}
          <br />
          <br />
          <br />
          <br />
        </>
      )}
	  </div>
      <div className="flex justify-center">
        {wallet.connected &&
          <button className="px-8 py-1.5 rounded bg-blue-400 text-white font-bold hover:bg-blue-600 hover:text-white"
            disabled={isSoldOut || isMinting || !isActive}
            onClick={onMint}
          >
            {isSoldOut ? (
              "SOLD OUT"
            ) : isActive ?
              <span>MINT {price} Sol {isMinting && ""}</span> :
              <Countdown
                date={mintStartDate}
                onMount={({ completed }) => completed && setIsActive(true)}
                onComplete={() => setIsActive(true)}
                renderer={renderCounter}
              />
            }
          </button>
        }
      </div>
    </main>
  );
};

const renderCounter = ({ days, hours, minutes, seconds, completed }: any) => {
  return (
    <span>
      {hours} hours, {minutes} minutes, {seconds} seconds
    </span>
  );
};

export default Mint;



`

but not work...

mainnet deploy doesn't work

Hi,
I get the following error while running yarn deploy-mainnet. (Tested successfully with devnet). Can you help?

Error uploading file 0 Error: failed to get recent blockhash: FetchError: request to https://api.mainnet-beta.solana.com/ failed, reason: connect ETIMEDOUT 45.159.5.254:443 at Connection.getRecentBlockhash (E:\Blockchains\Solana\NFTs\metaplex\js\packages\cli\node_modules\@solana\web3.js\src\connection.ts:2986:13) at processTicksAndRejections (internal/process/task_queues.js:95:5) upload was not successful, rerunning (node:122048) UnhandledPromiseRejectionWarning: Error: failed to get info about account 63N3bBDCVVzdCaofQAnY5s4kcZodw1evomptDgNQ4feK: FetchError: request to https://api.mainnet-beta.solana.com/ failed, reason: connect ETIMEDOUT 45.159.5.254:443 at Connection.getAccountInfo (E:\Blockchains\Solana\NFTs\metaplex\js\packages\cli\node_modules\@solana\web3.js\src\connection.ts:2443:13) at processTicksAndRejections (internal/process/task_queues.js:95:5) at async Function.fetchIdl (E:\Blockchains\Solana\NFTs\metaplex\js\packages\cli\node_modules\@project-serum\anchor\src\program\index.ts:309:25) (Usenode --trace-warnings ...to show where the warning was created)

How can I display my artworks in the index.tsx

Hi \how can I retrieve my artworks and display them in my index.tsx, which of the object holds the data or which component should I import?

Basically what am trying to achieve is pull the data and display it on the website so people can mint, and so it also show the status of each artwork whether it has been minted or not, So if there's a way that I can fetch the data I will like to know.

Really looking forward to your response ASAP if possible bro, your help will really be appreciated.
Thank you in advance

how to customize index.tsx?

i luv u kevin!
i don't have react app knowledge.
how to show up remain NFT count in webpage?
how to modify Mint Button style..?

Batch upload n number of NFTs

Say I already have my images and jsons formatted. Consider implementing a function which allows upload of these assets in batch

'yarn setup-dev' upload always fails.

When running yarn setup-dev after generating my sources, I get a loop of the same error. I have let this sit for several minutes and it always fails. I've ran it multiple times with the same process and I have never gotten it to work.

It seems like a Cloud Function is throwing an exception. Can we run this function locally instead, and is it open source?

upload was not successful, rerunning
Error uploading file 3 FetchError: invalid json response body at https://us-central1-principal-lane-200702.cloudfunctions.net/uploadFile4 reason: Unexpected token E in JSON at position 0
    at /snapshot/js/node_modules/node-fetch/lib/index.js:272:32
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  type: 'invalid-json'
}
Transaction simulation failed: Error processing Instruction 0: Program failed to complete 
    Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ invoke [1]
    Program log: libstd rust_begin_panic
    Program log: panicked at 'range end index 971 out of range for slice of length 255', nft-candy-machine/src/lib.rs:318:18
    Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ consumed 200000 of 200000 compute units
    Program failed to complete: BPF program panicked
    Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ failed: Program failed to complete
saving config line 0-2 failed SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete
    at Connection.sendEncodedTransaction (/snapshot/js/node_modules/@solana/web3.js/lib/index.cjs.js:4863:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Connection.sendRawTransaction (/snapshot/js/node_modules/@solana/web3.js/lib/index.cjs.js:4822:20)
    at async Object.sendAndConfirmRawTransaction (/snapshot/js/node_modules/@solana/web3.js/lib/index.cjs.js:6649:21)
    at async Provider.send (/snapshot/js/node_modules/@project-serum/anchor/dist/cjs/provider.js:84:22)
    at async Object.rpc [as addConfigLines] (/snapshot/js/node_modules/@project-serum/anchor/dist/cjs/program/namespace/rpc.js:11:31) {
  logs: [
    'Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ invoke [1]',
    'Program log: libstd rust_begin_panic',
    "Program log: panicked at 'range end index 971 out of range for slice of length 255', nft-candy-machine/src/lib.rs:318:18",
    'Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ consumed 200000 of 200000 compute units',
    'Program failed to complete: BPF program panicked',
    'Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ failed: Program failed to complete'
  ]
}

Edit candymachine rust program and deploy

I'm trying to implement a whitelist feature in my candy machine

I found what I should change and where, but I struggle to build and deploy the program

How should I proceed for deployment ? Does anyone have a script for that ?

[devnet] yarn setup-dev -> Transaction simulation failed

Hi Kevin!
I did managed to run yarn setup-dev once successfully before. But when I tried to redo it again, it gave this error after '[INFO] Creating candy machine'.

Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0 
    Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ invoke [1]
    Program 11111111111111111111111111111111 invoke [2]
    Allocate: account Address { address: AuT9D4SqRTTS4DtDvZgtVjE2GZJLaJ1792ra1ioZDWT8, base: None } already in use
    Program 11111111111111111111111111111111 failed: custom program error: 0x0
    Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ consumed 200000 of 200000 compute units
    Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ failed: custom program error: 0x0
(node:717) UnhandledPromiseRejectionWarning: Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0
    at Connection.sendEncodedTransaction (/Users/edwinzeng/metaplex-foundation/metaplex/js/node_modules/@solana/web3.js/src/connection.ts:3553:13)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Connection.sendRawTransaction (/Users/edwinzeng/metaplex-foundation/metaplex/js/node_modules/@solana/web3.js/src/connection.ts:3513:20)
    at async Object.sendAndConfirmRawTransaction (/Users/edwinzeng/metaplex-foundation/metaplex/js/node_modules/@solana/web3.js/src/util/send-and-confirm-raw-transaction.ts:27:21)
    at async Provider.send (/Users/edwinzeng/metaplex-foundation/metaplex/js/node_modules/@project-serum/anchor/src/provider.ts:112:18)
    at async Object.rpc [as initializeCandyMachine] (/Users/edwinzeng/metaplex-foundation/metaplex/js/node_modules/@project-serum/anchor/src/program/namespace/rpc.ts:19:23)

I have checked other sites. Someone mentioned the cache is not in sync. But I am not sure which cache folder they are referring to though.

I would like to know how I should resolve this issue. Thanks!

Problems executing shell scripts on a windows based nodejs installation

Hi
I've been having some issues while trying to set up a NFT playground using the candy factory.
After registering my nft on the strapi server and generating the nft sources, I can't execute the "yarn setup-dev" command.
Always getting this error message:

The command
"sh" is either misspelled or
could not be found.

The problem arises in the setup-metaplex-dev.js file when trying to execute the shell script:

shelljs.exec('sh .devtools/dev/setup-metaplex-dev.sh')

I've already tried fixing this by adding the git/bin directory to my enironvment variables in order to make "sh" known to Windows, without success though.

I'd be happy for some help on this one :)

Upload failed after 1200 successful ones

Received this after only 1200 files uploaded and it still charged me 18 SOL??? Is this SOL lost or are these images still usable? How do I use them and upload the rest?

\node_modules\rpc-websockets\dist\lib\client.js:392
this.socket.close(code || 1000, data);
^
TypeError: Cannot read properties of undefined (reading 'close')
at Client.close (C:\Users\gagew\metaplex\js\node_modules\rpc-websockets\dist\lib\client.js:392:19)
at Timeout._onTimeout (C:\Users\gagew\metaplex\js\node_modules@solana\web3.js\src\connection.ts:3820:30)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)

Mint issue: Error processing Instruction 4

Hello, thanks for this great project!

Setup

  • The site is running locally using devnet.
  • No changes to the repo code, only set NEXT_MINT_PRICE_SOL=0.01 in .env for testing purposes
  • I created a wallet on devnet using phantom and connected to the site.

Issue

I'm trying to mint 1 and getting this error:

A has_one constraint was violated

Translating error Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 4: custom program error: 0x8d

Full stacktrace

Transaction simulation failed: Error processing Instruction 4: custom program error: 0x8d 
    Program 11111111111111111111111111111111 invoke [1]
    Program 11111111111111111111111111111111 success
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]
    Program log: Instruction: InitializeMint
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2390 of 200000 compute units
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success
    Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]
    Program log: Transfer 2039280 lamports to the associated token account
    Program 11111111111111111111111111111111 invoke [2]
    Program 11111111111111111111111111111111 success
    Program log: Allocate space for the associated token account
    Program 11111111111111111111111111111111 invoke [2]
    Program 11111111111111111111111111111111 success
    Program log: Assign the associated token account to the SPL Token program
    Program 11111111111111111111111111111111 invoke [2]
    Program 11111111111111111111111111111111 success
    Program log: Initialize the associated token account
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]
    Program log: Instruction: InitializeAccount
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 3449 of 179576 compute units
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success
    Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 24522 of 200000 compute units
    Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL success
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]
    Program log: Instruction: MintTo
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2879 of 200000 compute units
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success
    Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ invoke [1]
    Program log: Custom program error: 0x8d
    Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ consumed 14615 of 200000 compute units
    Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ failed: custom program error: 0x8d

Checking the wallet instructions:

image

yarn setup-dev stalling at "[INFO] Setting minting start date (goLiveDate)"

I'm attempting to run yarn setup-dev however the script appears to stall at the [INFO] Setting minting start date (goLiveDate) phase no matter what timestamp I supply. I've tried multiple different time stamps in the future and past, with no success.

It does not progress past this line after waiting many minutes.
image

Error: Cannot find module './candy-machine-cli.ts'

An error occurred while I was running yarn setup dev๏ผš

Commitment: confirmed
[INFO] Sending airdrop
Requesting airdrop of 1 SOL

Signature: 34zyccUnVXAXa91Fe2ER33whZ2yafKkUm38xnugkw37AU2vSRz3bdUyvkCFur72vkzgPkRwPcib7SztMxRhCsPgS

1 SOL
$ node ./devtools/dev/setup-metaplex-dev.js
Type mint price [default 1 sol]:
Type start date of the minting [default 16 Sep 2021 00:00:00]:
[INFO] Cleaning older cache folder for metaplex
[INFO] Uploading all resources
internal/modules/cjs/loader.js:892
throw err;
^

Error: Cannot find module './candy-machine-cli.ts'
Require stack:

  • /home/ubuntu/metaplex-foundation/metaplex/js/packages/cli/src/imaginaryUncacheableRequireResolveScript
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.resolve (internal/modules/cjs/helpers.js:98:19)
    at requireResolveNonCached (/usr/local/lib/node_modules/ts-node/dist/bin.js:320:16)
    at getProjectSearchDir (/usr/local/lib/node_modules/ts-node/dist/bin.js:290:35)
    at main (/usr/local/lib/node_modules/ts-node/dist/bin.js:192:27)
    at Object. (/usr/local/lib/node_modules/ts-node/dist/bin.js:350:5)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/home/ubuntu/metaplex-foundation/metaplex/js/packages/cli/src/imaginaryUncacheableRequireResolveScript'
    ]
    }
    [INFO] Creating candy machine
    internal/modules/cjs/loader.js:892
    throw err;
    ^

Error: Cannot find module './candy-machine-cli.ts'
Require stack:

  • /home/ubuntu/metaplex-foundation/metaplex/js/packages/cli/src/imaginaryUncacheableRequireResolveScript
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.resolve (internal/modules/cjs/helpers.js:98:19)
    at requireResolveNonCached (/usr/local/lib/node_modules/ts-node/dist/bin.js:320:16)
    at getProjectSearchDir (/usr/local/lib/node_modules/ts-node/dist/bin.js:290:35)
    at main (/usr/local/lib/node_modules/ts-node/dist/bin.js:192:27)
    at Object. (/usr/local/lib/node_modules/ts-node/dist/bin.js:350:5)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/home/ubuntu/metaplex-foundation/metaplex/js/packages/cli/src/imaginaryUncacheableRequireResolveScript'
    ]
    }
    [INFO] Setting minting start date (goLiveDate)
    internal/modules/cjs/loader.js:892
    throw err;
    ^

Error: Cannot find module './candy-machine-cli.ts'
Require stack:

  • /home/ubuntu/metaplex-foundation/metaplex/js/packages/cli/src/imaginaryUncacheableRequireResolveScript
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.resolve (internal/modules/cjs/helpers.js:98:19)
    at requireResolveNonCached (/usr/local/lib/node_modules/ts-node/dist/bin.js:320:16)
    at getProjectSearchDir (/usr/local/lib/node_modules/ts-node/dist/bin.js:290:35)
    at main (/usr/local/lib/node_modules/ts-node/dist/bin.js:192:27)
    at Object. (/usr/local/lib/node_modules/ts-node/dist/bin.js:350:5)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/home/ubuntu/metaplex-foundation/metaplex/js/packages/cli/src/imaginaryUncacheableRequireResolveScript'
    ]
    }
    $ node ./devtools/dev/setup-envs-dev.js
    /home/ubuntu/py/solana-candy-factory/devtools/dev/setup-envs-dev.js:20
    .trim()
    ^

TypeError: Cannot read property 'trim' of undefined
at /home/ubuntu/py/solana-candy-factory/devtools/dev/setup-envs-dev.js:20:9
at Array.forEach ()
at /home/ubuntu/py/solana-candy-factory/devtools/dev/setup-envs-dev.js:13:9
at FSReqCallback.oncomplete (fs.js:180:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The code has not been changed

yarn dev - INVALID URL

Getting INVALID_URL when I go to localhost:3000

image

$ yarn dev
yarn run v1.22.15
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
event - compiled successfully
event - build page: /
wait - compiling...
event - compiled successfully
event - build page: /next/dist/pages/_error
wait - compiling...
event - compiled successfully
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:371:5)
at onParseError (node:internal/url:552:9)
at new URL (node:internal/url:628:5)
at new Connection (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory\node_modules@solana\web3.js\lib\index.cjs.js:3504:15)
at Object../src/hooks/use-wallet-balance.tsx (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\pages_app.js:37:20)
at webpack_require (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\webpack-runtime.js:25:42)
at Object../src/pages/_app.tsx (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\pages_app.js:104:83)
at webpack_require (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\webpack-runtime.js:25:42)
at webpack_exec (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\pages_app.js:275:39)
at C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\pages_app.js:276:28 {
input: 'undefined',
code: 'ERR_INVALID_URL'
}
error - TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:371:5)
at onParseError (node:internal/url:552:9)
at new URL (node:internal/url:628:5)
at new Connection (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory\node_modules@solana\web3.js\lib\index.cjs.js:3504:15)
at Object../src/hooks/use-wallet-balance.tsx (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\pages_app.js:37:20)
at webpack_require (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\webpack-runtime.js:25:42)
at Object../src/pages/_app.tsx (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\pages_app.js:104:83)
at webpack_require (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\webpack-runtime.js:25:42)
at webpack_exec (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\pages_app.js:275:39)
at C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\pages_app.js:276:28 {
input: 'undefined',
code: 'ERR_INVALID_URL',
page: '/'
}
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:371:5)
at onParseError (node:internal/url:552:9)
at new URL (node:internal/url:628:5)
at new Connection (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory\node_modules@solana\web3.js\lib\index.cjs.js:3504:15)
at Object../src/hooks/use-wallet-balance.tsx (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\pages_app.js:37:20)
at webpack_require (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\webpack-runtime.js:25:42)
at Object../src/pages/_app.tsx (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\pages_app.js:104:83)
at webpack_require (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\webpack-runtime.js:25:42)
at webpack_exec (C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\pages_app.js:275:39)
at C:\Users\Tarnnn\OneDrive\Desktop\sol-candy\solana-candy-factory.next\server\pages_app.js:276:28 {
input: 'undefined',
code: 'ERR_INVALID_URL'
}

generate-nfts-sources not working?

Hi everyone,

I've followed the guide from quicknode as well as the documentation from this very repo and after creating a collection and its NFTs, the command yarn update-creator-all-rows works as intended but then yarn generate-nfts-sources, after asking if I want to randomize or not is done in around 1-2 seconds and no outputs can be seen anywhere. They should be landing in the cloned repo folder under nfts-sources correct?

Thanks

Question: How to upload many (5-10k) Images?

Hey!

I've followed this blog which is very handy however, i can't see how i would be able to upload a collection of images at scale.

The only way i see it working is if i create my own script that loops over a folder of [png/json] assets and populates the nfts-sources folder.

Is this the recommended way? I can't see any documentation regarding uploading assets at scale, especially multiple assets with differing attributes.

Reopen - Update-creator-all-rows promise rejection

Originally posted by @kevinfaveri in #16 (comment)

Reopening. It definitely is different. Permissions should be fine.

C:\Users\XXXXXX\Documents\GitHub\solana-candy-factory>yarn update-creator-all-rows
yarn run v1.22.10
$ cd ./nft-manager && yarn update-creator-all-rows
$ node ./scripts/update-creator-all-rows
(node:21136) UnhandledPromiseRejectionWarning: Error
at Strapi.request (C:\Users\XXXXXX\Documents\GitHub\solana-candy-factory\nft-manager\node_modules\strapi-sdk-javascript\build\main\lib\sdk.js:59:23)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Strapi.login (C:\Users\XXXXXX\Documents\GitHub\solana-candy-factory\nft-manager\node_modules\strapi-sdk-javascript\build\main\lib\sdk.js:93:32)
at async updateCreatorAllRows (C:\Users\XXXXXX\Documents\GitHub\solana-candy-factory\nft-manager\scripts\update-creator-all-rows.js:32:3)
(Use node --trace-warnings ... to show where the warning was created)
(node:21136) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:21136) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Done in 0.34s.

I pulled fork starting from 4676f11

Will leave this here too:

image

Candy Machine Config accounts not 529 bytes

It looks to me like you have this backwards. The candy machine accounts should all have a constant value of 529 bytes but the config accounts will be highly variable depending on how many NFT config lines are stored in them.

How To Create A Seperate Database For Different Projects

Hi, I'm planning to use this repo. for a couple different projects in parallel.

I've cloned the repo. to two different folders on my local machine.

However, when I get to running yarn start-nft-manager-db an yarn nft-manager in my second folder, I'm pretty sure it's the same database again.

I say this because I don't get prompted to create a Strapi account (like I did the first time).

How it looks now:
Screenshot 2021-10-14 at 16 32 18

I have forgotten my Strapi account login (and can't recover it through the local machine).

Is there a way to have a seperate database for each folder / instance of the repo.?

Unable to deploy to the mainnet (What is wallet PK)

Hi Kevin, I just lost a job because I couldn't deploy it to the mainnet. Everything was working fine on the devnet but I had issues with the wallet PK.

Because I thought that the wallet PK was the public key but anytime I input it, it will just add to the mainnet.json file without converting it to a json file. And then the upload will be unsuccessful.
Any way on how I can sort this out.

I will really appreciate, thank you.

Minting more than one asset is showing wrong price on Phantom wallet

Thanks for this great project that I found after the comment you left on the candy-mint official project
(ref: metaplex-foundation/metaplex#363 (comment))

I did not made any changes to your code especially I left as is quantity: number = 2 in function const mintMultipleToken = async ( ... )

However when I click mint, the transition showing up if for the cost of one mint (instead of two).
Am I missing other changes to make to the code for the mint to mint more than one?

Thank you in advance!

cannot receive solana network api

i use vercel host.
first deploy on vercel. is nice work!

but setting my custom domain

cannot call solana network api haha example item remaning counts.

occured cors error

Minting site crashing

When I try to access the minting site spun up by yarn dev I get this error.

<--- Last few GCs --->

[1402:0x5192bc0] 27608 ms: Mark-sweep (reduce) 485.8 (495.3) -> 485.8 (496.3) MB, 677.6 / 0.0 ms (average mu = 0.078, current mu = 0.003) allocation failure scavenge might not succeed
[1402:0x5192bc0] 28281 ms: Mark-sweep (reduce) 486.8 (493.3) -> 486.8 (495.3) MB, 671.0 / 0.0 ms (average mu = 0.041, current mu = 0.004) allocation failure scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0xa25510 node::Abort() [/usr/bin/node]
2: 0x9664d3 node::FatalError(char const*, char const*) [/usr/bin/node]
3: 0xb9a8be v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/bin/node]
4: 0xb9ac37 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/bin/node]
5: 0xd56ca5 [/usr/bin/node]
6: 0xd5782f [/usr/bin/node]
7: 0xd6566b v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/bin/node]
8: 0xd6922c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/bin/node]
9: 0xd2e9fd v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/usr/bin/node]
10: 0xd28884 v8::internal::FactoryBasev8::internal::Factory::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [/usr/bin/node]
11: 0xd29323 v8::internal::FactoryBasev8::internal::Factory::NewByteArray(int, v8::internal::AllocationType) [/usr/bin/node]
12: 0xc84b6d v8::internal::Handlev8::internal::ByteArray v8::internal::SourcePositionTableBuilder::ToSourcePositionTablev8::internal::Isolate(v8::internal::Isolate*) [/usr/bin/node]
13: 0x1a310e8 v8::internal::compiler::CodeGenerator::FinalizeCode() [/usr/bin/node]
14: 0x1ac2a5b v8::internal::compiler::PipelineImpl::FinalizeCode(bool) [/usr/bin/node]
15: 0x1ac3b27 v8::internal::compiler::PipelineCompilationJob::FinalizeJobImpl(v8::internal::Isolate*) [/usr/bin/node]
16: 0xc64a20 v8::internal::OptimizedCompilationJob::FinalizeJob(v8::internal::Isolate*) [/usr/bin/node]
17: 0xc654b5 [/usr/bin/node]
18: 0xc66f9d v8::internal::Compiler::CompileOptimized(v8::internal::Handlev8::internal::JSFunction, v8::internal::ConcurrencyMode) [/usr/bin/node]
19: 0x106696e v8::internal::Runtime_CompileOptimized_NotConcurrent(int, unsigned long*, v8::internal::Isolate*) [/usr/bin/node]
20: 0x1426919 [/usr/bin/node]
Aborted

Error in generate sources after asking if I want to shuffle

I am getting this error after being asked if I want to shuffle no matter what i put as a response.

image
(node:3500) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, copyfile './publicundefined' -> '../nfts-sources/0.png'
at Object.copyFileSync (fs.js:2059:3)
at generateNftsSources (C:\Users\gagew\Documents\candy-factory\solana-candy-factory-main\nft-manager\scripts\generate-nfts-sources.js:65:8)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use node --trace-warnings ... to show where the warning was created)
(node:3500) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3500) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Done in 4.51s.

Cannot read property 'trim' of undefined when running yarn setup-dev

Hello,

Loving your project.

When running yarn setup-dev i get the error Cannot read property 'trim' of undefined

It's coming from around line 26 /devtools/dev/setup-envs-dev.js and looks like /logs/dev/candy-machine-start-date.txt is not being populated by the update_candy_machine command.

everything else seems to be working smoothly!

If the time is not reach starttime countdown should appear, but there is only MINT.

thanks to ur update!
but still countdown render in mint button not work
the time is not reach countdown should appear, but there is only MINT <<

const [isActive, setIsActive] = useState(false); // true when countdown completes

this countdown seems to will isActive value false > true change function but not work..

			onMount={({ completed }) => completed&& setIsActive(true)}

this code always change isActive const true..

Countdown is always being set to completed on first tick.

If remove onMount and onComplete it shows the proper countdown, but then it never updates to being active.

Upload was not successful, rerunning

Hi @kevinfaveri, thanks for your great effort on this project.

I run into this error after uploading and about 6 SOL has already been deducted. However I deployed it on the devnet and everything worked fine.

Writing indices 1720-1729
Writing indices 730-739
Writing indices 1730-1739
Writing indices 740-749
Writing indices 1740-1749
Writing indices 750-759
Writing indices 1750-1759
Writing indices 760-769
Writing indices 1760-1769
Writing indices 770-779
Writing indices 1770-1779
Writing indices 780-789
Writing indices 1780-1789
Writing indices 790-799
Writing indices 1790-1799
Writing indices 800-809
Writing indices 1800-1809
Writing indices 810-819
Writing indices 1810-1819
Writing indices 820-829
Writing indices 1820-1829
Writing indices 830-839
Writing indices 1830-1839
Writing indices 840-849
Writing indices 1840-1849
Writing indices 850-859
Writing indices 1850-1859
Writing indices 860-869
Writing indices 1860-1869
Writing indices 870-879
Writing indices 1870-1879
Writing indices 880-889
Writing indices 1880-1889
Writing indices 890-899
Writing indices 1890-1899
Writing indices 900-909
Writing indices 1900-1909
Writing indices 910-919
Writing indices 1910-1919
Writing indices 920-929
Writing indices 1920-1929
Writing indices 930-939
Writing indices 1930-1939
Writing indices 940-949
Writing indices 1940-1949
Writing indices 950-959
Writing indices 1950-1959
Writing indices 960-969
Writing indices 1960-1969
Writing indices 970-979
Writing indices 1970-1979
Writing indices 980-989
Writing indices 1980-1989
Writing indices 990-999
Writing indices 1990-1999
Done. Successful = false.

Please what should I do right now. Am really frustrated.
THank you.

Unhandled Runtime Error

Everything generates and uploads, creates id's, etc.., but i get an error when viewing the site.

Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'digest')

Source
src/utils/candy-machine.ts (168:20) @ _callee4$

166 | });
167 |

168 | const idl = await anchor.Program.fetchIdl(
| ^
169 | CANDY_MACHINE_PROGRAM,
170 | provider
171 | );
Call Stack
getCandyMachineState
src/utils/candy-machine.ts (159:33)
_callee2$
src/hooks/use-candy-machine.ts (82:12)
eval
src/hooks/use-candy-machine.ts (72:4)

Anything I could try?

yarn setup-dev displaying errors

Hi Kevin, thank you for taking your time to share knowledge and hence prepare the solana nft candy factory. I have everything working fine but when i run 'yarn set-dev' i run into the error below.

PS C:\Users\user\Desktop\nft_sol\solana-candy-factory> yarn setup-dev
yarn run v1.22.5
$ yarn setup-solana-dev && yarn setup-metaplex-dev && yarn setup-envs-dev
$ ./devtools/dev/setup-solana-dev.sh
$ node ./devtools/dev/setup-metaplex-dev.js
Type mint price [default 1 sol]:
Type start date of the minting [default 16 Sep 2021 00:00:00]:
'sh' is not recognized as an internal or external command,
operable program or batch file.
$ node ./devtools/dev/setup-envs-dev.js
C:\Users\user\Desktop\nft_sol\solana-candy-factory\devtools\dev\setup-envs-dev.js:33
NEXT_PUBLIC_TREASURY_ADDRESS = fileContent.toString().split('\n')[4].split(' ')[1].trim();
^

TypeError: Cannot read property 'split' of undefined
at C:\Users\user\Desktop\nft_sol\solana-candy-factory\devtools\dev\setup-envs-dev.js:33:75
at Array.forEach ()
at C:\Users\user\Desktop\nft_sol\solana-candy-factory\devtools\dev\setup-envs-dev.js:13:9
at FSReqCallback.oncomplete (fs.js:180:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Cannot read property 'split' of undefined?

yarn run v1.22.15
$ yarn setup-solana-dev && yarn setup-metaplex-dev && yarn setup-envs-dev
$ ./devtools/dev/setup-solana-dev.sh
$ node ./devtools/dev/setup-metaplex-dev.js
Type mint price [default 1 sol]:
Type start date of the minting [default 16 Sep 2021 00:00:00]:
'sh' is not recognized as an internal or external command,
operable program or batch file.
$ node ./devtools/dev/setup-envs-dev.js
C:\Users\nelso\Documents\candy factory\solana-candy-factory\devtools\dev\setup-envs-dev.js:33
      NEXT_PUBLIC_TREASURY_ADDRESS = fileContent.toString().split('\n')[4].split(' ')[1].trim();
                                                                          ^

TypeError: Cannot read property 'split' of undefined
    at C:\Users\nelso\Documents\candy factory\solana-candy-factory\devtools\dev\setup-envs-dev.js:33:75
    at Array.forEach (<anonymous>)
    at C:\Users\nelso\Documents\candy factory\solana-candy-factory\devtools\dev\setup-envs-dev.js:13:9
    at FSReqCallback.oncomplete (fs.js:179:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I am getting this error when I finally run the yarn setup-dev command, and it says that fileContent.toString().split('\n')[4] is undefined. I can't seem to figure out what is wrong.

Buffer overrun (re-open)

Hi Kevin!
I got this error when I tried deploying mainnet for 10 items.
Writing indices 0-9 saving config line 0-9 failed RangeError: encoding overruns Buffer at Blob.encode...
I noticed a similar problem on devnet, where I could only batch 8 items at one time.

I have not deleted the cache for mainnet. I was charged a bit of Sol as well.
What should I do next?

I am reading the other issue on restarting uploads.

Error when running yarn update-creator-all-rows

I get this error when running the update-creator command.

$ node ./scripts/update-creator-all-rows
(node:3303) UnhandledPromiseRejectionWarning: Error: [object Object]
at Strapi.request (/root/solana-candy-factory/nft-manager/node_modules/strapi-sdk-javascript/build/main/lib/sdk.js:59:23)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Strapi.login (/root/solana-candy-factory/nft-manager/node_modules/strapi-sdk-javascript/build/main/lib/sdk.js:93:32)
at async updateCreatorAllRows (/root/solana-candy-factory/nft-manager/scripts/update-creator-all-rows.js:32:3)
(Use node --trace-warnings ... to show where the warning was created)
(node:3303) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:3303) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Done in 0.47s.

Not sure why.

not work nft manager.

cloning solana-candy-factory. yarn install & build.
solana-candy-factory mint machine is nice work.
but nft manager is not work.
i set postgresql on 6432 and add su permission admin / Admin123
but strapi password incorrect message output with not proceed

Error response from daemon: Ports are not available: unable to list exposed ports

When running yarn --verbose start-nft-manager-db, I get the following:

$ docker compose up
Attaching to postgres_1
Error response from daemon: Ports are not available: unable to list exposed ports: Get "http://unix/forwards/list": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
verbose 1681.084214192 Error: Command failed with exit code 1.
    at ProcessTermError.ExtendableBuiltin (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:721:66)
    at ProcessTermError.MessageError (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:750:123)
    at new ProcessTermError (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:790:113)
    at /usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:34550:30
    at Generator.throw (<anonymous>)
    at step (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:310:30)
    at /usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:323:13
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

How to fix this?

yarn setup-dev ~> "A has_one constraint was violated"

Hello again!
I am trying to upload 100 assets to devnet and after a few minutes wait and what looks like a positive upload then spits out a constant never-ending stream of errors (see below)

I've pulled latest on metaplex and run yarn bootstrap

Are you seeing this issue your end?
My file names are incrementing numbers e.g 0.png, 1.png etc...

Transaction simulation failed: Error processing Instruction 0: custom program error: 0x8d 
    Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ invoke [1]
    Program log: Custom program error: 0x8d
    Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ consumed 16007 of 200000 compute units
    Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ failed: custom program error: 0x8d
Translating error SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x8d
    at Connection.sendEncodedTransaction (/Users/[redacted]/metaplex-foundation/metaplex/js/node_modules/@solana/web3.js/src/connection.ts:3553:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Connection.sendRawTransaction (/Users/[redacted]/metaplex-foundation/metaplex/js/node_modules/@solana/web3.js/src/connection.ts:3513:20)
    at async Object.sendAndConfirmRawTransaction (/Users/[redacted]/metaplex-foundation/metaplex/js/node_modules/@solana/web3.js/src/util/send-and-confirm-raw-transaction.ts:27:21)
    at async Provider.send (/Users/[redacted]/metaplex-foundation/metaplex/js/node_modules/@project-serum/anchor/src/provider.ts:112:18)
    at async Object.rpc [as addConfigLines] (/Users/[redacted]/metaplex-foundation/metaplex/js/node_modules/@project-serum/anchor/src/program/namespace/rpc.ts:19:23) {
  logs: [
    'Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ invoke [1]',
    'Program log: Custom program error: 0x8d',
    'Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ consumed 16007 of 200000 compute units',
    'Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ failed: custom program error: 0x8d'
  ]
}
saving config line 0-9 failed ProgramError: 
    at Function.parse (/Users/[redacted]/metaplex-foundation/metaplex/js/node_modules/@project-serum/anchor/src/error.ts:36:14)
    at Object.rpc [as addConfigLines] (/Users/[redacted]/metaplex-foundation/metaplex/js/node_modules/@project-serum/anchor/src/program/namespace/rpc.ts:23:42)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  code: 141,
  msg: 'A has_one constraint was violated'
}
Writing indices 10-19

0.json example

{
    "name": "OG_SLOG#1",
    "symbol": "[REDACTED]",
    "seller_fee_basis_points": 500,
    "image": "0.png",
    "attributes": {
        "Primary Color": "Green",
        "Secondary Color": "Purple",
        "Skin Pattern": "Swirl_Large",
        "Eye Pattern": "Eye_Pattern_B",
        "Pupil Pattern": "Pupil_Pattern_A",
        "Skin Bumpy": "0.5",
        "Metalic A": "0.25",
        "Metalic B": "0.5",
        "Roughness A": "0.25",
        "Roughness B": "0.1",
        "Primary Shade": "9.0",
        "Secondary Shade": "11.0"
    },
    "properties": {
        "creators": [{
            "address": "[REDACTED]",
            "share": 100
        }],
        "files": [{
            "uri": "0.png",
            "type": "image/png"
        }]
    }
}

ReCaptcha is useless

That ReCaptcha is useless because it is only being checked on the client side.

Anybody can bypass the captcha with just a little skill in programming.

Or am I missing something?

Strapi Not Found

Hi!

When I got to run "yarn nft-manager" I get the following error:

"Error loading the local develop command. Strapi might not be installed in your "node_modules". You may need to run "npm install"
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command."

I have Strapi installed. Not sure what I'm doing wrong. Thanks for any help!

nf-ts is forbidden

Hi! Thanks for the cool lib

Running into a problem where nf-ts is returning forbidden?
I triple checked to make sure I set the User to have role authenticated username: admin and password: Admin123

Any help would be greatly appreciated.. i'm sure i am just missing something from the docs thanks

Build

Yarn build not working.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.