Custom Credentials: Smart Contract Queries

Learn how to use contract queries in your campaigns. Verify if an address has interacted with or used a smart contract in a certain way.

Zeno avatar
Written by Zeno
Updated over a week ago

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.

You can utilize this credential via the curated credential section or your dashboard!

How to Add a Contract Query to Your Galxe Campaigns

Like any other credential, you can add a contract query directly to your Campaigns on Galxe during the last step of the campaign creation process.

To create a contract query in your campaigns on Galxe:

  1. Enter a Title for the Credential

  2. Select the Network the Contract is Deployed on (Chain)

  3. Create a contract query credential.

    1. Galxe uses the contract methods to check a user's address, so you must define the desired output.

  4. 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:

  1. Select the Network where the Contract is deployed

  2. Input the Smart Contract Address

  3. 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

  1. 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

  1. 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.

    1. If the address parameter doesn't represent the user's address, manually input the required address.

    2. You need to provide default values for other parameter types (uint, int, string, bytes, bytes1/2/4/8/16/32, and bool).

⭐️ 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

  1. The method's outputs, as returned by your ABI, will be listed in order. Assign each output a display name and description.

  2. 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.

Prove your knowledge, and try to configure your first Contract Query Credential!


Did this answer your question?