Skip to content
This repository was archived by the owner on Dec 2, 2025. It is now read-only.

TokenGate Guard disconnects Guard ID #10

@S4tyras

Description

@S4tyras

As we try to add a TokenGate to it we get a "Account does not have correct owner" warning from the UI

creating the config.json guard in sugar seems to disconnect the guard from the candy-machine:
"guards": {
"default": {

  "mintLimit": {
    "id": 1,
    "limit": 1
  },
  "startDate": {
    "date": "2024-04-01 06:00:00 +0000"
  },
  "endDate": {
    "date": "2024-04-02 18:00:00 +0000"
  },
  "tokenGate": {
    "amount": 100000,
    "mint": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
  }
}

}

For now we ended up in adding the token Gate at the end and define the public key, but I am not sure if this is correct.
If we only define the tokenGate in the index.tsx and not in the candy-machine config in suger, we get another error: "Public Key mismatch"

const enabledGuardsKeys =
  guards && Object.keys(guards).filter((guardKey) => guards[guardKey])

let mintArgs: Partial<DefaultGuardSetMintArgs> = {}


const tokenMintPublicKeyString = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
const tokenMint = publicKey(tokenMintPublicKeyString);

// If there are enabled guards, set the mintArgs
if (enabledGuardsKeys.length) {
  // Map enabled guards and set mintArgs automatically based on the fields defined in each guard
  enabledGuardsKeys.forEach((guardKey) => {
    const guardObject = unwrapOption(candyGuard.guards[guardKey]);
    if (!guardObject) return null;

    mintArgs = { ...mintArgs, [guardKey]: some(guardObject) };
  });
}

mintArgs.tokenGate = some({ mint: tokenMint });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions