metaplex-foundation / js-examples

Examples and Starter Kits using the new JS SDK
MIT License
79 stars 92 forks source link

TypeError: Cannot read properties of null (reading 'guards') #37

Open yukosgiti opened 1 year ago

yukosgiti commented 1 year ago

Hello, I was trying to have the ui mint example to run. And I got the following message:

TypeError: Cannot read properties of null (reading 'guards')

The error happens at line 79 of MintNFTs.js.

const guard = candyMachine.candyGuard.guards;

My sugar config is like this:

{
  "number": 5,
  "symbol": "XX",
  "sellerFeeBasisPoints": 500,
  "isMutable": true,
  "isSequential": false,
  "creators": [
    {
      "address": "<address>",
      "share": 100
    }
  ],
  "uploadMethod": "pinata",
  "awsConfig": null,
  "nftStorageAuthToken": null,
  "shdwStorageAccount": null,
  "pinataConfig": {
    "jwt": "<token>",
    "apiGateway": "https://api.pinata.cloud",
    "contentGateway": "https://gateway.pinata.cloud",
    "parallelLimit": 1
  },
  "hiddenSettings": null,
  "guards": null
}

address and token are of course are changed to my wallet and key

I believe it assumes there will be guards? How can I get the UI to run?

falbanese90 commented 1 year ago

Looks like you left out a step when setting up your candy machine. You have to add guards to the config file. Wasn't always the case but I believe this minting tutorial is based on Candy Machine V3, where it's necessary.

MarkSackerberg commented 1 year ago

Hey @yukosgiti, did @falbanese90 post help you? Are you still seeing issues?

yukosgiti commented 1 year ago

Thanks! I assumed if I didn't provide it, it would automatically do it (because there is an option withoutCandyGuard)

qudo-code commented 1 year ago

Currently stuck on this, what fixed it? Screenshot 2023-03-23 at 8 53 00 PM

Snoobie commented 1 year ago

@qudo-code If you scroll to this part in documentation https://docs.metaplex.com/programs/candy-machine/how-to-guides/my-first-candy-machine-part1#candy-guards---further-configuration You will see the guards part with those parameters

"guards": {
    "default": {
      "mintLimit": {
        "id": 1,
        "limit": 3
      },
      "solPayment": {
        "value": 0.5,
        "destination": "Tes1zkZkXhgTaMFqVgbgvMsVkRJpq4Y6g54SbDBeKVV"
      },
      "startDate": {
        "date": "2022-10-23T20:00:00Z"
      }
    }

Add this guard section updating those guards with what you want to do in your config.json and the run those command sugar guard add && sugar guard update

Hope it's clear

tanlethanh commented 1 year ago

You can add some of the available guards as the above comment to pass the error. But to handle this case, we can ignore the guard handlers in case it does not exits.

image

Some parts still get this error, just ignore it like above.