<aside> đź‘‹ Functions allow program managers to issue points by manipulating contract events with more advanced custom logic - such as holding a token as a function of time, or getting more points for taking an action early (e.g. early minter). Functions can be written in javascript and built directly on Stack.so to make it easy to test and refine.

</aside>

Popular Earn Activities Functions on Known Contract Events

Popular Earn Activities Guide

Step-by-step instructions

1. Navigate to the integrations page from the dashboard and select “Functions on contract events”

Functions_1.gif

2. Select “configure” to create a function

Functions_2.gif

3. Select the chain and enter the contract address, contract ABI, and event you wish to issue points against.

<aside> âť“ To get the contract ABI for a contract on a block explorer like Etherscan or Basescan, click the contract tab and scroll to the Contract ABI section.

</aside>

Functions_3.gif

4. Define how points are issued based on your selected event and preview the function

<aside> âť“ Stack makes it easy to issue points from an event in a smart contract by automatically the parameters associated with it. You need to know the specific event you are looking for in a given smart contract, you can easily issue points.

For example, using the Base x Atari NFT contract, we can select the event GameMintedwhich is emitted when a user mints the NFT.

Points Issuance Expression
5 for minting points: 5
5 per NFT minted 5 * (endTokenId - startTokenId)
</aside>

Functions_4.gif

Goal Type Event Expression
Issue points as function of # of months subscribed Hypersub Subscription Purchase timePurchased / 2592000

5. Create function