Create Your First Condition Based Job
This tutorial will guide you through the process of automating a smart contract function using TriggerX's condition-based trigger system. We'll cover everything from understanding the contract to deploying a condition-driven job that executes a smart contract function based on real-time data from an external API.
Understanding the Smart Contract
Contract Functionality:
The smart contract we'll use contains a function helloWorld that increments a stored value by a specified amount each time it’s called.

Why Automate with TriggerX
Manually monitoring conditions (like ETH price or market activity) is inefficient and error-prone. TriggerX enables automated, real-time execution of smart contract functions based on predefined conditions, eliminating delay and increasing reliability.
Step-by-Step Guide to Creating an Event-Based Job
Access the TriggerX App: Navigate to the TriggerX application and connect your wallet.
Navigate to 'Create Job': On the home page, click on the "Start Building" button. By default, this opens the custom job creation page.

Select Trigger Type: Choose Condition-Based Trigger. This will set your job to execute a smart contract function only when a specific condition is met.
Enter Job Title: Give your job a meaningful title
Choose Network: Select OP Sepolia as the network where your contract is deployed.
Set Timeframe: Set the duration for which the job should actively listen for events. For example, choose 1 day.
Choose Recurrence: Indicate whether this job should be: Recurring (executed every time the event is emitted) One-Time (executed only once on the first event) Choose the desired option based on your automation needs.
Enter Contract Address: Input the address of the contract whose function you want to call when the event is triggered:
0x6bd14b295B10821c53AB92613593786A623fa612ABI Handling:
If your contract is verified on the blockchain explorer, TriggerX will automatically fetch the ABI.
If it’s not verified, manually input the ABI during this step.
Select Function to Trigger: From the available functions in the contract, choose:
helloWorldDefine Function Arguments:
Argument Type:
Static: Provide a fixed value that will be used each time the function is called.
Dynamic: Fetch the value dynamically from an API or an IPFS-hosted script.
For Static Argument: Enter the value directly. For example, to increment by
1every time the event occurs, input1.For Dynamic Argument: Provide the IPFS link to your script that dynamically fetches the value. (Templates and documentation are available in the TriggerX DevHub).
Enter Source Type:
You’ll now define the source from which the condition will be monitored.
Choose between:
API
WebSocket
Oracle (currently disabled, under development)
For this tutorial, we’re selecting the API.
Enter Source URL:
Enter the API URL from which to fetch the condition data: For this example, we will use:
https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usdEnter Condition Type:
Choose from the following comparison options:
Equals To
Not Equal To
Less Than
Greater Than
In Range
Less Than or Equal To
Greater Than or Equal To
We're using In Range.
Define Limits:
Set the range within which the condition should trigger the function:
Lower Limit:
2972Upper Limit:
2976
For this example, if the ETH price in USD is between 2972 and 2976, the
helloWorldfunction will be triggered.Finalize and Create Job: Click the “Create Job” button. While the system calculates the necessary fees, enjoy a mini-game featuring a man collecting food. Once the fee estimation is complete, click “Next” to finalize your job creation.

Summary
You’ve now successfully set up a condition-based job on TriggerX!
Whenever the ETH price falls within the defined range, TriggerX will automatically execute your helloWorld function, incrementing the value stored in your smart contract, hands-free!
For more advanced features, customization, and templates, check out the TriggerX DevHub.
Last updated