What is a Contract Query Credential?
The Contract Query credential lets you call functions on a smart contract to check whether a user meets your requirements.
Add a contract query to your campaigns as a credential to verify if a user has interacted with or used a smart contract in a certain way.
How to Add a Contract Query to Your Galxe Campaigns
Like any other credential, you can add a contract query directly to your quests on Galxe during the last step of the campaign creation process.
To create a contract query in your quests on Galxe:
Enter a title for the Credential
Select the network the contract is deployed on (Chain)
Create a contract query credential.
Galxe uses the contract methods to check a user's address, so you must define the desired output.
Specify the criteria for the outputs.
βοΈ Tip: You can utilize any publicly available contract to create a query!
Creating Contract Query Credentials
To create a contract query, you'll need to enter a few pieces of information:
Select the network where the contract is deployed
Input the smart contract address
Enter the contract ABI
For Customized RPC's you'll need the following details:
Network name
RPC URL
Contract address
π Example: Here is an example of an RPC URL
β
βhttps://base.publicnode.com
Enter the Smart Contract Details
First, get the address of the smart contract.
When you input a contract address, we will fill the ABI for you if the contract is verified.
If the ABI field is blank, you need to input the ABI by yourself.
Define the Methods and Outputs
Defining the methods and outputs based on your ABI is crucial to employing a practical contract query credential in your campaign.
Selecting the Method
Choose the Method: Select the method you wish to query from your ABI.
β
If there are no selectable methods, it might indicate a need to switch the contract or use the correct ABI for the current contract.
β
Filling in Method Inputs
Specify Method Inputs: For inputs of type address, the system will automatically use the $address placeholder to fill in the user's address during queries.
βοΈ Tip: For bytes type, values should start with 0x.
βFor bool type, use true, True, false, or False.
Setting Up Contract Query Outputs
Configure Outputs
The method's outputs, as returned by your ABI, will be listed in order. Assign each output a display name and description. The display name should not contain special characters.
βSelect the decimals option if the output is of the uint256 type and related to balance. Selecting decimals tells the system to divide the output value by the contract's provided decimal for storage and usage.
β
β
βΉοΈ Note: The Display Name and Description appear on the credential's detail page and the campaign usage page.
Specify Other Information: Block Height (Snapshot)
To check an address's activities on a specific block height (time), please turn on the snapshot switch and input the block number.
By default, the snapshot switch is off. Galxe will automatically fetch values from the most recent block height when the snapshot is off.
Once the snapshot switch is enabled, input the block number for which you wish to query user activities.
Test the Address
Input an address and test whether it works.
The test response will return all the defined outputs regarding your test address. If all values meet your expectations, that means it works.
Example of a Contract Query Credential
To review an example of a contract query credential, click here.
It should look like this π
Launch a Campaign With a Contract Query
Following the above steps, you can add contract query credentials to your campaigns on Galxe.
With a contract query credential, check if an address has interacted with your smart contracts and add flexibility to your campaign tasks.
Remember, follow us on Twitter/X, join our Discord community and subscribe to our Newsletter to stay updated.