js-examples icon indicating copy to clipboard operation
js-examples copied to clipboard

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

Open yukosgiti opened this issue 2 years ago • 6 comments

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?

yukosgiti avatar Feb 20 '23 14:02 yukosgiti

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.

falbanese90 avatar Feb 25 '23 04:02 falbanese90

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

MarkSackerberg avatar Feb 28 '23 19:02 MarkSackerberg

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

yukosgiti avatar Mar 01 '23 12:03 yukosgiti

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

qudo-code avatar Mar 24 '23 03:03 qudo-code

@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

Snoobie avatar May 07 '23 18:05 Snoobie

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.

tanlethanh avatar Jul 06 '23 17:07 tanlethanh