Nerif Docs
  • Quickstart
  • Tutorials
    • Lottery Tutorial
      • Step 1. Configure your account
      • Step 2. Add a smart contract
      • Step 3. Create a new automation workflow
      • Step 4. Build your automation workflow
      • Step 5. Test workflow execution
    • Bridge Tutorial
      • Step 1. Configure your account
      • Step 2. Add smart contracts
      • Step 3. Create a new automation workflow
      • Step 4. Build your automation workflow
      • Step 5. Test workflow execution
    • Price Feed Tutorial
      • Step 1. Configure your account
      • Step 2. Add smart contract
      • Step 3. Create a new automation workflow
      • Step 4. Build your automation workflow
  • 1. What is Nerif Network?
    • Our Mission
    • Our Vision
    • Terms
  • 2. Architecture
    • Core components
    • Validators
      • Networking
        • Bootnode
        • Joining the network
        • Leaving the network
        • Slashing
      • Consensus
        • Epoch & Rounds
        • Automation workflow
          • Triggers
          • Actions
          • Condition
    • Contracts
      • System Contracts
      • Operational Contracts
    • Security
      • DKG
      • Threshold ECDSA
      • Security checks
  • 3. How it works
    • Introduction
    • Nerif App
    • Login
    • Account Configuration
      • 1. Deploy a Gateway Contract
        • 1.1 Create a new gateway
        • 1.2. Use existing gateway contract
        • 1.3.What if I want to update my gateway contract?
      • 2. Top up your balance
        • 2.1. Topping up your balance on Polygon Mumbai
        • 2.2. Topping up your balance on Ethereum Goerli
    • Fees
    • User balance
      • 1. Topping up the balance
        • 1.1 Top up your balance via Nerif App
        • 1.2 Top up your balance directly via Registry smart contract
      • 2. Withdraw from balance
        • 2.1 Withdraw via Nerif App
        • 2.2 Withdraw directly via Registry smart contract
    • API
      • Off-chain APIs
      • On-chain APIs
    • SDK
  • 5. Nerif DAO
    • Governance
    • Treasury
    • Proposal process
  • 6. Support
Powered by GitBook
On this page
  1. Tutorials
  2. Lottery Tutorial

Step 4. Build your automation workflow

PreviousStep 3. Create a new automation workflowNextStep 5. Test workflow execution

Last updated 1 year ago

First, we click on “Add step” and press “Action” to add a new workflow element.

Select (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!

eth_call