All Collections
Credentials & Rewards
Credentials 101 🍎
Credential Setup ⚙️
Step-by-Step: Using a Subgraph Credential to Customize Campaign Tasks
Step-by-Step: Using a Subgraph Credential to Customize Campaign Tasks

At Galxe, you can create credentials that work with Subgraphs, offering an efficient and unique way to engage Web3 communities.

Operation Team avatar
Written by Operation Team
Updated over a week ago

What is a Subgraph Credential?

With Subgraphs, you can get creative and create an exceptional experience with your Galxe campaigns.

Subgraphs work by interpreting data from a blockchain in a human-readable way. 👩‍🏫

Using a Subgraph to query data allows for a ton of versatility within your campaigns.

You can utilize data schemas to read large amounts of blockchain data— providing you with targeted access to specific types of data from the blockchain, like historical participation, holders of particular assets, addresses that interact with smart contracts, etc.


Article Sections


How do I use Subgraph Credentials?

At Galxe, you can directly create credentials that work with Subgraphs, which offers an efficient way to target specific addresses or users of your products.

With Curated Credentials, you can streamline the process of using Subgraph Credentials and gain valuable insights tailored to your needs— without stressing out about creating a custom query for a subgraph.

This is how requests work:

Galxe.com

Request

Galxe's Backend

Request

Your backend

User Address

Input
➡️

GraphQL Query
(Based on configuration)

Input
➡️

Endpoint

Credential

Output
⬅️

Expression Result
(Either 1 or 0 / T or F)

Output
⬅️

Response

Using Subgraph Credentials on Galxe

Whether you're managing NFT Holder data or tracking Campaign Participants, the Subgraph expands the credential creation process and allows for maximum customization.

For Subgraph Credentials, you can conveniently update qualified addresses from thegraph.com.

Experience the ease and effectiveness of subgraph integration with our examples.

Examples of Subgraph Credentials:

ℹ️ Note: The design of Subgraph Credentials limits their use cases to on-chain tasks.

Adding Subgraph Credentials to Your Campaigns

Select "On-Chain" and find "Subgraph" from the Credential Dashboard 👇

Customizing Subgraph Credentials: Required Fields

When users try verifying their address on Galxe, we utilize a GraphQL Query.

The user's address gets passed in as the argument and then sent to the specified endpoint.

After we receive a response, the result gets converted into an expression which determines eligibility. (Either 1 or 0 / True or False)

When creating a Subgraph Credential, three required fields (3) need to be filled.

Required Fields:

  1. Endpoint

  2. Query

  3. Expression.

Endpoint

An HTTPs endpoint is where Subgraph queries get executed.

Reference the example below 👇

Ensuring your endpoint is valid and working correctly is extremely important for a Subgraph or GraphQL based Credential.

If the API is incorrectly configured then data will NOT get exchanged properly.

Common misconfigurations include:

  1. incorrectly used a GraphQL playground url, that usually ends with /graph,

  2. incorrectly used a URL to the subgraph explorer page, like https://thegraph.com/explorer/***.

⭐️ Tip: The correct endpoint for a subgraph looks something like this:

https://api.thegraph.com/subgraphs/***

Query

A query allows you to check whether an address is eligible for a Credential or not.

It also defines the conditions and criteria for determining eligibility.

Queries using GraphQL also utilize the GraphQL language, defined by these specifications.

ℹ️ Note: When testing a query, make sure to format the address in lower case.

AND

Double-check the query for spelling errors and inconsistencies in the format.

Expression

In this section, you should include JavaScript code that converts the results of the Query into 0/1 outputs.

There are only two options: Qualified (1) or not qualified (0).

A value of 0 means the queried address is not eligible, while a value of 1 means the address is eligible.

If you get an incorrect result from the expression, there is an error in the expression format, query or endpoint.

ℹ️ Note: The result from an expression uses a 'boolean' variable.

1 for True or 0 for False.

Subgraph Examples for NFT Holder and Campaign Participants

Reference the examples below for creating Subgraph Credentials for NFT Holders or Campaign Participants.

Credential Example: Campaign Participants

Endpoint

https://graphigo.prd.galaxy.eco/query

Query

query userInfo($address: String!) {
campaign(id: "xxxx") {
claimedTimes(address: $address)
}
}

Expression

function(data) {
if (data != null && data.campaign != null && data.campaign.claimedTimes > 0) {
return 1
}
return 0
}

Credential Example: NFT Holders

Endpoint

https://graphigo.prd.galaxy.eco/query

Query

query isNFTHolder($address: String!) {
campaign(id: “XXXX”) {
isNFTHolder(address: $address)
}
}

Expression

function(data) {
if (data.campaign != null && data.campaign.isNFTHolder) {
return 1;
}
return 0;
}

⭐️ Tips:

  • Taking XXXX as the campaign id (from end of campaign URL

  • These examples are only meant for OAT/NFT campaigns based on Galxe


Subgraph & GraphQL Credential FAQs

Frequently asked questions about GraphQL and Subgraph Credentials.

Wondering what some of the terms are? Refer to this Glossary of Graph terms.

Users getting 403 error?

Make sure the endpoint has whitelisted our server:

44.240.68.227
35.81.233.163

CORS Error (Server Request Not Allowed)

For security reasons, you must add https://galxe.com to your GraphQL server's Access-Control-Allow-Origin header to avoid CORS issues.

Galxe will perform a CORS check during the creation process, and if it's not included, the creation will fail.

⚠️ Wait: We require that requests must be responded to within 5 seconds.

Otherwise, the request will get cancelled.

Now You're Ready to Create Subgraph Credentials

Since this article equips you with knowledge of Subgraphs, you can take advantage of them within your campaigns on Galxe and stand out from the others across the Galxe. 💫

Go ahead and customize your heart out!

Additional examples of Subgraph Credentials:

If you are a Space owner/admin on Galxe, create new credentials here.


Did this answer your question?