Quickstart

Welcome to the Nerif Network, a decentralized cross-chain smart contract automation platform that aims to revolutionize dApp execution processes and accelerate the adoption of Web3 technology.

This quickstart guide is intended to walk you through the steps to deploy your first automation workflow in an easy-to-follow format.

For a more in-depth breakdown of the Nerif Network's capabilities and Nerif App's functionalities, including comprehensive tutorials, please visit the "How it works" chapter. If you're new to Nerif Network or simply looking for a quick way to get started, keep reading - you're in the right place!

1: Log in to the Nerif App

To access the Nerif Network, simply log in to the Nerif App using your Metamask wallet by clicking on "Login" and signing a message in your Metamask wallet.

2: Deploy a Gateway Contract

Before building the automation workflow, you’ll need to set up a gateway on those chains that are going to be used for sending transactions within workflows (other non-transaction actions, like eth_call, don't require it).

The gateway contract acts as a secure entry point for transactions from the registry to the customer contract, ensuring each transaction is associated with a designated workflow of a trusted user before forwarding it.

To deploy and register a new gateway contract within the Registry, click on "Chains" and choose the network you want to use - for instance, Polygon Mumbai in the example below.

Next, click on “Set up Gateway” in a box with the desired chain.

After that, you’ll be presented with two options to set up a gateway:

  1. Use Existing

  2. New Gateway

To deploy and register a new gateway contract within the Registry, click on “New Gateway”.

After that, all you need to do is to confirm three transactions in your wallet:

  1. Deploy gateway contract on the selected chain.

  2. Set the deployed gateway contract address per registry.

Once you confirm the transactions in your wallet, your Gateway contract is all set.

3: Top Up your Balance

To cover the execution of automation workflows, it is essential to top up your account balance. However, please note that this is only necessary for chains involved in sending transactions within workflows.

To add tokens to your balance, first, press “Top up”.

After that, select the number of tokens you want to add to your balance (e.g. 0.1 MATIC), click on “Top up” and confirm the transaction in your wallet.

Once you get the below message, tokens (e.g. MATIC) are added to your balance within the Registry. You can withdraw them anytime.

4: Add Smart Contracts

Nerif Network simplifies the automation of smart contract functions by allowing you to add your smart contract to the Nerif App. The app will then analyze the contract and its functions, enabling you to easily select the specific functions you want to automate from a convenient drop-down list when building your automation workflow.

To add a smart contract, you'll first need to have your smart contract deployed using Remix or any other preferred tool.

After that, just click on “Contracts” and:

1) Paste in the contract address;

2) Select the respective network (e.g. Polygon Mumbai);

3) Add a name (optional), such as "My first smart contract".

Finally, allow Nerif App to automatically determine contract ABI (subject to a contract being verified). If the contract is not publicly verified on the blockchain explorer (e.g. polygonscan), you’ll need to specify contract ABI manually.

Press “Create Contract” to complete the process.

5: Create a New Automation Workflow

Creating an automation workflow using the Nerif App is extremely straightforward.

First, click on “New Workflow” in the top right corner.

After that, type in the name of your workflow and add a description, if needed, then click on “Next”.

6: Select a Trigger

The Nerif App allows users to automate smart contract functions with a wide range of triggers.

The choice of a trigger is 100% based on your automation needs:

  • Do you want to trigger your functions based on specific events occurring on the blockchain? Choose the "Event" trigger.

  • Are you interested in the time-based execution of your smart contract functions (e.g. every minute, every week, once a month, etc)? Look no further than the "Cron-rule" trigger.

  • Want to tie your automation to the arrival of a new block or every N of blocks? Then, the "Block" trigger is what you need.

Once you made up your mind on the type of trigger to kick off your automation workflow, click on the desired trigger (e.g. "Block")and then press "Next".

This action of yours will automatically create a basic automation workflow, as in the example below.

7: Customize the Details of the Automation Workflow

Now, we've reached the core of building an automation workflow, where we can customize the workflow by configuring triggers, adding "Actions", and setting "Conditions" to tailor it to our specific needs.

Customizing Triggers

The triggers in the Nerif App are highly customizable. Let's quickly explore how to modify them.

Block

A block-based trigger allows users to trigger automation upon the arrival of a new block or every N of blocks.

To customize the "Block" trigger in your automation workflow, follow these steps:

  1. Click on the "Block" box.

  2. Select the desired chain.

  3. Specify the period number, such as "50", in the "Block period" field.

  4. Press "Confirm" to complete the trigger customization.

This will ensure that your automation is triggered after every 50th block is mined or emitted on the specified chain.

Cron-rule

The cron-rule trigger allows you to schedule the execution of your smart contract functions at specific time intervals, such as every minute, every week, or once a month. This provides flexibility in automating your desired actions within defined periods of time.

To customize the "Cron-rule" trigger in your automation workflow, follow these steps:

  1. Click on the "Block" box.

  2. Specify the time interval, such as "Minutes", "Hourly", "Daily", "Weekly", "Monthly", or "Custom".

  3. Enter further details for a selected time interval.

  4. Press "Confirm" to complete the trigger customization.

For instance, if you want the automation to be triggered during workdays at 09:30, repeat the actions in the example below.

Event

The "Event" trigger starts the automation workflow once a specific event is emitted by a specific smart contract.

Before customizing the "Event" trigger, make sure that you added a smart contract, as shown in "4: Add Smart Contracts".

To customize the "Event" trigger in your automation workflow, follow these steps:

  1. Click on the "Event" box.

  2. Select chain to interact with.

  3. Choose a smart contract

  4. Specify an event within a smart contract that will trigger automation workflow.

  5. Press "Confirm" to complete the trigger customization.

Following these instructions, let's assume that we've added a smart contract that allows for the transfer of arbitrary data from Ethereum Goerli to Polygon Mumbai. We'd want to trigger workflow execution when Send event is emitted with chain ID 80001 (i.e. chain ID of Polygon Mumbai) on the Ethereum Goerli chain within the bridge contract.

To implement this within our trigger, we do the following:

  1. Select Ethereum Goerli as a chain to interact with.

  2. Choose the contract we added previously.

  3. Select an event that will be triggering an automation workflow, which is event Send.

When Send event is clicked in the Nerif App, it will display fields from the event such as chainID, target, payload, gasAmount, and sender.

Finally, given that we want the automation workflow to be triggered if the receiver's chain ID specified in the event is Polygon Mumbai, we enter the chain ID for Polygon Mumbai into the field chainId, i.e. 80001, and click “Confirm”.

Adding Actions

Actions are the steps within a workflow that are performed in a decentralized or pseudo-decentralized manner.

To add an Action, click on "Add step" and select "Action".

This will open a new tab allowing you to select the type of actions you want to implement within your workflow.

At the moment, the Nerif App supports three types of actions: eth_call, transactions, and webhooks.

eth_call

eth_call is a type of action that executes a smart contract function call without creating a transaction or modifying the blockchain state.

To tailor the "eth_call" action to your automation needs, follow these steps:

  1. Click on the "Eth_call" box.

  2. Select chain to interact with.

  3. Choose a smart contract you've added previously.

  4. Select the needed smart contract function in a drop-down list.

Following these instructions, let's assume that we've added a smart contract ("Lottery") that checks if there are at least two participants taking part in a lottery and, then, selects the winners among the participants.

To implement this within our action, we configure the eth_call in the manner shown below.

Transactions

Transactions are actions that involve including transaction data and signatures generated by network participants, enabling changes to the blockchain state

To customize the "Transaction" type of action, follow these steps:

  1. Click on the "Transaction" box.

  2. Select chain to interact with.

  3. Choose a smart contract you've added previously.

  4. Input the gas limit number.

  5. Select the needed smart contract function in a drop-down list.

Following these instructions, let's assume that we'll be automating a lottery smart contract functions and that our smart contract received a confirmation that there is a desired number of participants in the lottery.

Now, we want the automation workflow to proceed further to pick up the winners. To implement this within our action, we configure the "Transaction" in the manner shown below.

Webhooks

Webhook is an action that includes request data and network signatures, typically used for integrating with external systems.

To customize the "Webhook" type of action, follow these steps:

  1. Click on the "Webhook" box.

  2. Specify the HTTP request method from a drop-down list (GET, POST, or DELETE).

  3. Enter the URL address of the webhook.

  4. Specify the authorization header by including the API key directly in the authorization header of the API request.

Let's assume that we want our workflow to check the price of the ETH/USDT pair at coinapi.io. To implement this within our action, we configure the "Webhook" in the manner shown below.

Setting Conditions

In the Nerif App, a Condition is a logical statement used to evaluate and determine the flow of an automation workflow based on specific criteria or conditions being met.

To add a Condition, click on "Add step" and select "Condition".

To configure a Condition in the Nerif Network, you need to define a variable, operator, and value. Let's explore customizing a Condition using the example of a lottery smart contract automation.

Suppose we have an "eth_call" Action that executes the function "playerExist". In this case, we can use a Condition to check if the desired number of participants is present in the lottery.

For example, if the function "playersExist" returns "true" when there are at least two participants, as illustrated below.

When adding a Condition in the Nerif Network, you have two options for the outcome once the Condition is evaluated:

  • "False" if the Condition is not met.

  • "True" if the Condition is met.

In the Nerif App, you have the flexibility to customize the subsequent steps of your automation workflow based on the outcome of the Condition evaluation.

You can add an Action, set a new Condition, or choose to exit and halt the workflow execution.

8: Deploy the Automation Workflow

Deploying an automation workflow with the Nerif App is a simple process. When you're satisfied with your workflow, click on "Publish" in the top right corner and confirm the transaction in your wallet to make your workflow live within the Nerif Network.

Last updated