Documentation
Off-chain App

Off-chain App

The Off-chain app allows you to create tasks that are completed off-chain. This is useful when you need to verify task completion through external APIs or services. In this guide, we'll walk you through the process of setting up an Off-chain Rest API Task in your campaign.

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 Off-chain App

You can view all the available apps on the left panel. Choose the Offchain app and select Offchain Rest-api task app.

Select offchain Select Offchain Rest API Task

Step 3: Configure the Off-chain App

Configure Offchain

To configure the Off-chain 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. In the following example, we're using a Google Sheets endpoint:

https://script.google.com/macros/s/AKfycbxg3PcfYm64GBJdLlGwyPRFYwQ5Ne0FzYgLvTmCaGXkQIrCLTIVlxVMUSBgBMfAoQZSIA/exec (opens in a new tab)

3.2 API Query

If you need to send any query parameters to the endpoint, you can do so. For instance:

walletAddress={WALLET_ADDRESS}&email={EMAIL}&sheetName=January-2023&column=1

In this case, {WALLET_ADDRESS} will contain the participant's wallet address, and {EMAIL} will contain the participant's verified email address (if it exists).

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": [
        [
            "0x781XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX354A"
        ]
    ]
}

For invalid users, it returns the following response:

{
    "data":[]
}

The expression to validate the above two responses would be:

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

Step 4: Submit Your Campaign

Once you've finished all the steps, click the "Save changes" button at the top right corner of the dashboard. Your Off-chain Rest API Task Campaign is now ready!

And that's it! You've successfully set up an Off-chain Rest API Task campaign. Users can now complete tasks off-chain and earn rewards on your campaign.