Step 4. Build your automation workflow
Last updated
Last updated
First, we click on “Add step” and press “Action” to add a new workflow element.
Select eth_call (an Ethereum API method that executes a smart contract function call without creating a transaction on the blockchain, it does not change a state) and press “Confirm”.
Now, we need to specify the chain, select the contract we added previously in Step 2, and choose the needed smart contract function in a drop-down list. After that, click “Confirm”.
Next, we want our Nerif Network to check if there are at least two participants in the lottery. To do that, click on “Add step” and select “Condition”.
Enter the details for Condition, as in the example below. In this case, the function playersExist
will return "true" if there are at least two participants in the lottery.
After that, we have two options for what happens once Nerif Network checks if there are at least two participants in the lottery, i.e. “false” and “true”.
For "false", click “Add step” and select “Exit”. This means that if there are not at least 2 participants in the lottery, the automation workflow does not proceed further.
For "true", click “Add step” and select “Action”.
Assuming there are at least two participants in the lottery, we want the automation workflow to proceed further to pick up the winners. To do that, we choose “Transaction” as our action type.
Now, let’s add the needed details for the transaction, as per the example below. We specify the Polygon Mumbai chain, select the lottery contract address in a drop-down list, set the gas limit, and choose the function pickWinner
. Again, this part of the automation workflow will only take place if there are at least two participants in the lottery.
After we put in all the transaction details, click “Confirm”.
Now, let’s specify how often we want the functions of our contract to be automated. To do that, click on “Cron-rule” and enter the details for the trigger. In this example, we want the workflow to be triggered once a day at 01:00 am. Once you decide on the specifications, press “Confirm”.
Finally, click “Publish” in the top right corner and confirm the transaction in your wallet to publish your workflow within Nerif Network. After that, your automation workflow is all set, congrats!