Skip to main content
In this example, you want a certain proposal to pass/fail, and want to incentivize users to swing votes in your favor by offering additional rewards.

See the code

See the full example code
Make sure you’ve completed the quick start guide before proceeding with this example.

Set up a Managed Budget

First you’ll need to either initialize a new budget, or use an existing one, and allow the budget to spend a certain amount of your selected ERC20.

Define The Action

Next you’ll need to define the action that qualifies a user to claim the reward. For Agora, we want to reward users that vote for a specific proposal on Agora. To do this, we’ll key off of the VoteCast event, which has the event signature VoteCast(address indexed,uint256,uint8,uint256,string).
There is also a VoteCastWithParams event. The SDK can only validate one at a time (for now), so this tutorial will just check for the VoteCast event.A workaround for this is to create one boost for VoteCast and another boost for VoteCastWithParams.
VoteCast Event

'VoteCast' Event Structure. Take note of the proposalId and support fields which are at index 1 and 2.

Here is how you can structure the EventActionPayload to target the VoteCast event.
If you’re using a known event, you can use the selectors package to get the signature.
Next, we need to define the action claimant and create the payload for the new event action. The eventAction payload consists of the actionClaimant and the actionSteps we defined previously. The purpose of the eventAction is to track and reward users based on their interactions with the specified event.
  1. actionClaimant: This object defines the conditions under which a user is eligible to claim rewards. It includes:
    • signatureType: Specifies that the signature type is an event.
    • signature: The event signature we are targeting, in this case, the VoteCast event.
    • fieldIndex: Indicates which field in the event data we are interested in; here, it targets the ‘voter’ address (the address that initiated the vote).
    • targetContract: The address of the contract we are monitoring for the event.
  2. actionSteps: This array can contain up to four action steps that outline the specific actions or conditions that must be met for the event action to be valid. In this example, we include the previously defined eventActionStepOne and eventActionStepTwo.
Next, we use core.EventAction to set up the event action with our constructed eventActionPayload.

Deploy the Boost

Once the event action is created, we can set up the incentives and deploy our boost.
core.OpenAllowList() makes this boost available to all addresses. If you want to limit it to a specific address, you can use a SimpleAllowList.

Claiming Incentives

Once a claimant has successfully voted, you can claim the incentive for that claimant. You will need the address of the user that cast the vote, the hash of the vote cast transaction, and the boost id. But first, you’ll need to implement some logic to determine the variable reward amount.
ERC20VariableIncentive uses off-chain logic to determine the reward amount. If you would like to base your reward on on-chain logic, you can use the ERC20VariableCriteriaIncentive type.
Once the reward amount is determined, we can generate the signature payload to allow us to claim the reward for the claimant. To generate the signature payload you will need to call the Boost /signatures api endpoint with the following params:
  • boostId: The id of the boost where the action was completed. The format is chainId:boostId (e.g. 8453:0x378632819f39c74c4f56b1429e760739c5fb51b7:12)
  • txHash: The hash of the transaction that completed the action.
  • claimData: This is only nessecary for variableIncentives. For this parameter you would pass in the rewardAmount which is used to determine the amount of the incentive to claim. If you have more than one variable incentive you can pass in a comma-separated list of claimData values.
The signatures api will return an array of signatures, one for each available incentive on the boost.

Claim Signature API

See additional documentation on how to build a claim signature
There can be multiple incentives to claim in a single boost. The example shown only has one incentive.
The boost will stay active until the maxParticipants set for the boost is reached, or the incentive budget is fully spent.