Once an end user has completed a boosted action, the boost reward can be claimed by submitting a transaction signed by the end user on the chain of the reward token.

Prerequisites for claiming a boost include:

  • the boost factory contract ABI, which can be found here
  • a signature from the Boost API vouching that a specific end user has completed the action for a currently active boost

Getting a boost completion signature

Before submitting the claim transaction, a signature verifying the completion of the specific boost action by the end user must be requested from the /boosts/get-signature endpoint.

const getSignatureResponse = await fetch('https://api.boost.xyz/boosts/get-signature', {
  method: 'POST',
  headers: {
    'Content-type': 'application/json',
  },
  body: JSON.stringify({
    boostId: '44aa700e-dad7-41cc-beee-73cce9f60598',
    address: '0x242c295e88760559a6ca8e8f02bb52cdcf7f7422'
  })
});

const { signature, compressedBytes, fee } = await getSignatureResponse.json();

While the raw signature is available in the response, the compressedBytes parameter of the response can be passed directly to the claim transaction below. Additionally, the required protocol fee to claim the boost is available in the response for convenience.

Claiming a boost reward

The following example demonstrates a claim of a reward in $DEGEN token on Base using the viem package and the compressedBytes param from the previous section:

import { type WalletClient, type PublicClient } from 'viem';
import boostFactoryAbi from './abis/boostFactory';

async function claimBoostReward(
  publicClient: PublicClient,
  walletClient: WalletClient,
  compressedBytes: string, // taken from GET/boosts/get-signature response
  fee: string, // taken from GET/boosts/get-signature response
) {
  const { request } = await publicClient.simulateContract({
    account: walletClient.account.address,
    address: '0x52629961F71C1C2564C5aa22372CB1b9fa9EBA3E', // boost factory contract
    abi: boostFactoryAbi,
    functionName: 'claimCompressed',
    args: [compressedBytes as Hex],
    value: BigInt(fee),
  });

  const txHash = await walletClient.writeContract(request);
}

Batching claims

For applications where batching of user claims is preferable, use the /boosts/get-signature-batch endpoint to query multiple signatures at once:

const getSignatureBatchResponse = await fetch('https://api.boost.xyz/boosts/get-signature-batch', {
  method: 'POST',
  headers: {
    'Content-type': 'application/json',
  },
  body: JSON.stringify([
    {
      boostId: '44aa700e-dad7-41cc-beee-73cce9f60598',
      address: '0x242c295e88760559a6ca8e8f02bb52cdcf7f7422'
    },
    {
      boostId: '44aa700e-dad7-41cc-beee-73cce9f60598',
      address: '0x242c295e88760559a6ca8e8f02bb52cdcf7f7422'
    },
  ])
});

const signatureObjects = await getSignatureBatchResponse.json();

Note that individual signature request failures fail silently for the /boosts/get-signature-batch endpoint, resulting in the failing signature requests being omitted from the response. To get error information on a specific signature request failure, use the singular /boosts/get-signature endpoint.