createTokenGatingRule

This mutation to create the group with single or multiple rules for gating. in token gating we have two cases one is positive gating and negative gating

Positive Gating:-

if the owner's NFT matches with the gating rule e.g. rule-contract address, rule contract token exists in the owner token list, the owner is eligible for gating.

Negative Gating:-

If the owner's NFT matches with the gating rule e.g. rule-contract address, rule contract token exists in the owner token list, the owner is not eligible for gating.

Sample mutation

mutation createTokenGatingRule($input: gatingInput!) {
  createTokenGatingRule(input: $input) {
    id
    groupName
    description
    status
    tokenGateType
    networkID
    createdAt
    organizationID
    rules {
      id
      gatingGroupId
      ruleType
      isNegativeGating
      isEligibleApproval
      approvalStatus
      rules {
        ... on ContractAddressGatingRes {
          contractAddress
        }
        ... on ContractAddressWithTokenIDGatingRes {
          contractAddress
          tokenID
        }
        ... on MetaDataGatingRes {
          metaData {
            key
            value
          }
        }
        ... on ContractAddressWithMetaDataGatingRes {
          contractAddress
          metaData {
            key
            value
          }
        }
        ... on ContractAddressWithTokenIDAndMetaDataGatingRes {
          contractAddress
          tokenID
          metaData {
            key
            value
          }
        }
        ... on OnchainGatingRes {
          onchain
        }
      }
      gatingWebhook {
        webhookContract {
          marketplaceCollectionItemId
          contractAddress
          onchainContractType
        }
      }
    }
  }
}

Sample variable

change parameter such rule depends on the ruleType.

RuleType: MetaData

{
  "input": {
    "orgID": "5a198d09-e243-491f-991a-f79e1cecdcc3",
    "networkId": "b260424b-bb37-4a3e-86d0-0866175e5e68",
    "groupName": "TESTTT GATING RULE",
    "groupId": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
    "description": "TESTTT",
    "status": "Active",
     "tokenGateType": "API",
    "rule": [
      {
        "ruleType": "MetaData",
        "metaData": {
          "metaData": [
            {
              "key": "title",
              "value": "tokenName"
            },
            {
              "key": "description",
              "value": "token description"
            }
          ]
        }
      }
    ]
  }
}

RuleType: ContractAddress

{
  "input": {
    "orgID": "5a198d09-e243-491f-991a-f79e1cecdcc3",
    "networkId": "b260424b-bb37-4a3e-86d0-0866175e5e68",
    "groupName": "TESTTT GATING RULE",
    "groupId": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
    "description": "TESTTT",
    "status": "Active",
    "tokenGateType": "API",
    "rule": [
      {
        "ruleType": "ContractAddress",
        "contractAddress": {
          "contractAddress": "0x8924def9bee0f61e010a7b7c39c4723e6e097383"
        }
      }
    ]
  }
}

RuleType: ContractAddressWithTokenID

{
  "input": {
    "orgID": "5a198d09-e243-491f-991a-f79e1cecdcc3",
    "networkId": "b260424b-bb37-4a3e-86d0-0866175e5e68",
    "groupName": "TESTTT GATING RULE",
    "groupId": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
    "description": "TESTTT",
    "status": "Active",
     "tokenGateType": "Contract",
    "rule": [
      {
        "ruleType": "ContractAddressWithTokenID",
        "contractAddressWithTokenId": {
          "contractAddress": "0x40d30dedfae0a66cf51f10b04036411d6f65fac6",
          "tokenID": 1
        }
      }
    ]
  }
}

RuleType: ContractAddressWithTokenIDAndMetaData

{
  "input": {
    "orgID": "5a198d09-e243-491f-991a-f79e1cecdcc3",
    "networkId": "b260424b-bb37-4a3e-86d0-0866175e5e68",
    "groupName": "TESTTT GATING RULE",
    "groupId": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
    "description": "TESTTT",
    "status": "Active",
     "tokenGateType": "API",
    "rule": [
      {
        "ruleType": "ContractAddressWithTokenIDAndMetaData",
        "isNegativeGating": true,
        "contractAddressWithTokenIdAndMetaData": {
          "contractAddress": "0xb00bde6257cb5fe75526540a39ead91012c44a80",
          "tokenID": 1,
          "metaData": [
            {
              "key": "title",
              "value": "tokenName"
            },
            {
              "key": "description",
              "value": "token description"
            }
          ]
        }
      }
    ]
  }
}

RuleType:ContractAddressWithMetaData

{
  "input": {
    "orgID": "5a198d09-e243-491f-991a-f79e1cecdcc3",
    "networkId": "b260424b-bb37-4a3e-86d0-0866175e5e68",
    "groupName": "TESTTT GATING RULE",
    "groupId": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
    "description": "TESTTT",
    "status": "Active",
     "tokenGateType": "API",
    "rule": [
      {
        "ruleType": "ContractAddressWithMetaData",
        "contractAddressWithMetaData": {
          "contractAddress": "0xab8860756e7e8995e7945d455058f71a9544c83d",
          "metaData": [
            {
              "key": "trait_type",
              "value": "color"
            },
            {
              "key": "value",
              "value": "red"
            }
          ]
        }
      }
    ]
  }
}

RuleType: ContractAddress
if we need to track the smart contract sale transaction, we can subscribe to the webhook call of the smart contract sale for token gating sync., it's eligible for all kinds of token-gating rules.

{
  "input": {
    "orgID": "5a198d09-e243-491f-991a-f79e1cecdcc3",
    "networkId": "b260424b-bb37-4a3e-86d0-0866175e5e68",
    "groupName": "TESTTT GATING RULE",
    "groupId": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
    "description": "TESTTT",
    "status": "Active",
    "tokenGateType": "API",
    "rule": [
      {
        "ruleType": "ContractAddress",
        "webhookInput": {
          "webhookContract": [
            {
              "contractAddress": "0x0EdB7bBb3538412F99845f619BCb2dCC0A230708",
              "onchainContractType": "TokenGating"
            }
          ]
        },
        "contractAddress": {
          "contractAddress": "0x4530c707F7d3ED86d3A2788dd994703036a17c4d"
        }
      }
    ]
  }
}

RuleType: onChain

{
  "input": {
    "orgID": "5eb26a32-2a2f-4f4a-88fa-e92fad02b67d",
    "networkId": "b260424b-bb37-4a3e-86d0-0866175e5e68",
    "groupName": "test claimable gating",
    "groupId": "7dae2ad9-d67d-484c-9f90-3135f7f2d83a",
    "tokenGateType": "Contract",
    "rule": {
      "ruleType": "Onchain",
      "onchain": {
        "onchain": "ONCHAIN"
      }
    }
  }
}

Multiple Rule :

{
  "input": {
    "orgID": "5a198d09-e243-491f-991a-f79e1cecdcc3",
    "networkId": "b260424b-bb37-4a3e-86d0-0866175e5e68",
    "groupName": "TESTTT GATING RULE",
    "description": "TESTTT",
    "status": "Active",
    "tokenGateType": "API",
    "rule": [
      {
        "ruleType": "ContractAddress",
        "contractAddress": {
          "contractAddress": "0x8924def9bee0f61e010a7b7c39c4723e6e097383"
        }
      },
      {
        "ruleType": "ContractAddressWithTokenID",
        "contractAddressWithTokenId": {
          "contractAddress": "0x40d30dedfae0a66cf51f10b04036411d6f65fac6",
          "tokenID": 1
        }
      },
      {
        "ruleType": "ContractAddressWithTokenIDAndMetaData",
        "isNegativeGating": true,
        "contractAddressWithTokenIdAndMetaData": {
          "contractAddress": "0xb00bde6257cb5fe75526540a39ead91012c44a80",
          "tokenID": 1,
          "metaData": [
            {
              "key": "title",
              "value": "tokenName"
            },
            {
              "key": "description",
              "value": "token description"
            }
          ]
        }
      },
      {
        "ruleType": "ContractAddressWithMetaData",
        "contractAddressWithMetaData": {
          "contractAddress": "0xab8860756e7e8995e7945d455058f71a9544c83d",
          "metaData": [
            {
              "key": "trait_type",
              "value": "color"
            },
            {
              "key": "value",
              "value": "red"
            }
          ]
        }
      },
      {
        "ruleType": "MetaData",
        "metaData": {
          "metaData": [
            {
              "key": "title",
              "value": "tokenName"
            },
            {
              "key": "description",
              "value": "token description"
            }
          ]
        }
      },
      {
        "ruleType": "ContractAddress",
        "webhookInput": {
          "webhookContract": [
            {
              "contractAddress": "0x0EdB7bBb3538412F99845f619BCb2dCC0A230708",
              "onchainContractType": "TokenGating"
            }
          ]
        },
        "contractAddress": {
          "contractAddress": "0x4530c707F7d3ED86d3A2788dd994703036a17c4d"
        }
      }
    ]
  }
}

Sample response

{
  "data": {
    "getGatingRules": {
      "id": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
      "groupName": "TESTTT GATING RULE",
      "description": "TESTTT",
      "status": "Active",
      "networkID": "b260424b-bb37-4a3e-86d0-0866175e5e68",
      "organizationID": "5a198d09-e243-491f-991a-f79e1cecdcc3",
      "createdAt": "2024-01-18T15:39:59.785332+05:30",
      "tokenGateType":"API",
      "rules": [
        {
          "id": "9638cb9a-c640-4c79-beba-f966782c77af",
          "gatingGroupId": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
          "ruleType": "ContractAddressWithTokenIDAndMetaData",
          "isNegativeGating": true,
          "rules": {
            "contractAddress": "0xb00bde6257cb5fe75526540a39ead91012c44a80",
            "tokenID": 1,
            "metaData": [
              {
                "key": "title",
                "value": "tokenName"
              },
              {
                "key": "description",
                "value": "token description"
              }
            ]
          },
          "gatingWebhook": null
        },
        {
          "id": "09e86db0-9dec-4663-8c24-092883be4dea",
          "gatingGroupId": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
          "ruleType": "ContractAddress",
          "isNegativeGating": false,
          "rules": {
            "contractAddress": "0x8924def9bee0f61e010a7b7c39c4723e6e097383"
          },
          "gatingWebhook": null
        },
        {
          "id": "af8214b2-bfea-467a-b477-6083ad18bb7c",
          "gatingGroupId": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
          "ruleType": "ContractAddressWithTokenID",
          "isNegativeGating": false,
          "rules": {
            "contractAddress": "0x40d30dedfae0a66cf51f10b04036411d6f65fac6",
            "tokenID": 1
          },
          "gatingWebhook": null
        },
        {
          "id": "d47e2919-7ee1-4215-907d-f448aa4c1913",
          "gatingGroupId": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
          "ruleType": "ContractAddressWithMetaData",
          "isNegativeGating": false,
          "rules": {
            "contractAddress": "0xab8860756e7e8995e7945d455058f71a9544c83d",
            "metaData": [
              {
                "key": "trait_type",
                "value": "color"
              },
              {
                "key": "value",
                "value": "red"
              }
            ]
          },
          "gatingWebhook": null
        },
        {
          "id": "1c23e49f-e202-404b-ad22-07b0975b7f59",
          "gatingGroupId": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
          "ruleType": "MetaData",
          "isNegativeGating": false,
          "rules": {
            "metaData": [
              {
                "key": "title",
                "value": "tokenName"
              },
              {
                "key": "description",
                "value": "token description"
              }
            ]
          },
          "gatingWebhook": null
        },
        {
          "id": "f9450795-18c0-4cb4-8e10-72db783d16eb",
          "gatingGroupId": "8884306e-e6d1-437a-826e-035ec7e2d4ed",
          "ruleType": "ContractAddress",
          "isNegativeGating": false,
          "rules": {
            "contractAddress": "0x4530c707F7d3ED86d3A2788dd994703036a17c4d"
          },
          "gatingWebhook": {
            "webhookContract": [
              {
                "marketplaceCollectionItemId": null,
                "contractAddress": "0x0EdB7bBb3538412F99845f619BCb2dCC0A230708",
                "onchainContractType": "TokenGating"
              }
            ]
          }
        }
      ]
    }
  }
}

Arguments

NameTypeDescription
inputObjectContains all the information about from gatingInput

Fields

NameTypeDescription
GatingGroupsObjectContains information about from GatingGroups such as group name, group id, rules and etc..