# Trigger Functions

1. **setPubId();**

```solidity
function setPubId(
        uint256 actionId, 
        string memory pubId, 
        string memory actionName
    ) external onlyWav3sTrigger {
```

| Parameter  | Type    | Description                                                                                                                                                          |
| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| actionId   | uint256 | Action ID returned by fundAction()                                                                                                                                   |
| pubId      | string  | A string that identifies a publication in a social graph. Prefixes are used to uniquely identify publication from different social graphs, like "lens-0x01a2ee-0x09" |
| actionName | string  | Action names are "mirror", "like", "comment", "post", "follow", "collect", and so on.                                                                                |

This function is used to bound the settings stored in an Action ID with a corresponding publication ID and an "action name". An Action ID is returned each time a fundAction() is executed.&#x20;

2. **processAction();**

```solidity
function processAction(
        string memory pubId,
        string[] memory action,
        address[] memory user,
        uint256[] memory variableCount
    ) external stopInEmergency onlyWav3sTrigger
```

| Parameter     | Type       | Description                                                                                                                                   |
| ------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| pubId         | string     | The string that identifies a publication in a social graph.                                                                                   |
| action        | string\[]  | An array of actions that were engaged and areprocessed. Action names are "mirror", "like", "comment", "post", "follow", "collect", and so on. |
| user          | address\[] | A correlating array of the users addresses that engaged with the actions input.                                                               |
| variableCount | uint256\[] | An array of arbitrary values used as filters for the action being processed.                                                                  |

Triggers will call this function after reading engagements on wav3s posts with the information of the zurfers that engaged. If the user fill the requiremets the reward will be transfered to them. If the action being processed is a raffle, then the function will store the valid zurfers waiting to the executiong of the raffle.&#x20;

An event is emitted each time an action in processed with the user address and the pubId of the post.

```solidity
emit Events.wav3s__ActionProcessed(_user, pubId);
```

If the budget of the publication is over after the processing of the action, an "Action Finished" event is emitted

```solidity
emit Events.wav3s__ActionFinished(pubId, _action);
```

3. **executeRaffle();**

```solidity
function executeRaffle(
        string memory pubId, 
        string memory actionName
      ) external stopInEmergency onlyWav3sTrigger {
```

| Parameter  | Type   | Description                                                                           |
| ---------- | ------ | ------------------------------------------------------------------------------------- |
| pubId      | string | The string that identifies a publication in a social graph.                           |
| actionName | string | Action names are "mirror", "like", "comment", "post", "follow", "collect", and so on. |

With both pubId and actionName, the trigger can command the execution of a Raffle related to both inputs. The raffle will only succed if the "raffle duration" time has passed, and at least there is enough amount of zurfers in the list as rewards has the raffle.

When a prize of the raffle is paid, an event is emitted:

```solidity
emit Events.wav3s__PrizePaid(
    actionDataBase.pubId,
    actionDataBase.actionName,
    indexOfWinner, 
    winner, 
    _reward);
```

If the prizes are over, an Action Prize Finished event is emitted:&#x20;

```solidity
emit Events.wav3s__ActionPrizeFinished(
    actionDataBase.pubId, 
    actionDataBase.actionName
    );
```

5. getWinners();

```solidity
function getWinners(
    string memory pubId,
    string memory actionName
    ) public view returns (address[] memory) {
```

| Parameter  | Type   | Description                                                                           |
| ---------- | ------ | ------------------------------------------------------------------------------------- |
| pubId      | string | The string that identifies a publication in a social graph.                           |
| actionName | string | Action names are "mirror", "like", "comment", "post", "follow", "collect", and so on. |

By calling getWinners() with a specified pubId and actionName, if the action was a raffle, the function will return an array containing all the addresses of the winners of the raffle.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://zurfsocial.gitbook.io/zurf/technical-stuff/contracts/trigger-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
