Documentation
Solana Chain

On-chain API Task App Guide for Solana Chain

In this guide we will walk you through the process of setting up an on-chain activity verification API for Solana with two examples.

To do this we will use the On-chain API task app to setup the verification.

Step 1: Create a new campaign

Create a new campaign: Start by creating a new campaign. Refer this guide to learn how to launch a new campaign: Create and launch a Campaign.

Step 2: Add the On-chain API task App

You can view all the available apps on the left panel. Choose the Onchain option and select Onchain API task app.

Select onchain

Select Onchain Task

Step 3: Configure the On-chain API Task App

Configure Onchain API task

To configure the On-chain API task app, you need to provide the following details in the right panel:

3.1 API Endpoint

The endpoint can be a custom one on your own server, or you can utilize external endpoints.

3.2 API Query

This is a query that will be run to determine whether the user's task completion is valid.

For example:

query = walletAddress={WALLET_ADDRESS}

3.3 API Expression

If you need to apply any logic to the response data to determine whether the user's task completion is valid, you can define an expression.

For example if the endpoint returns the following response when a user's task completion is valid:

{
    "data": {
        "balance": 10000
    }
}

And for invalid users, it returns the following response:

{
    "data": {
        "balance": 0
    }
}

Then the expression to validate user having a balance greater than 0 would be:

function (response) {
    if (response.data && response.data.balance > 0) {
        return 1;
    } else {
        return 0;
    }
}

Step 4: Save and Submit Your Campaign

Once you've finished all the steps, click the "Save changes" button at the top right corner of the dashboard. Your On-chain API task app campaign is now ready!