TriggerX Docs
  • Introduction
    • What is TriggerX?
    • Key Features
  • Core Concepts
    • Architecture
    • Triggers in TriggerX
      • Time-Based Trigger
      • Event-Based Trigger
      • Condition-Based Trigger
    • Task Manager
    • Keepers
      • Keeper as Performer
      • Keeper as Attester
    • Aggregator
    • Network Monitoring
    • Contracts
      • AVS Governance
      • Attestation Center
  • Getting Started as Keepers
  • Monitoring And Analytics
    • Monitor Your Keeper
    • Monitor Your Job
  • Rewards
    • Keeper Rewards
    • Developer Rewards
    • Contributor Rewards
  • Fee Calculation
  • Guide
    • Templates
    • Usecases
  • Security Model
  • Community and Support
  • Appendices
    • Glossary
    • FAQ and Troubleshooting
    • Changelogs
  • References
  • Create Your First Job
    • Create Your First Time Based Job
    • Create Your First Event Based Job
Powered by GitBook
On this page
  • Template 1: Checking Condition
  • Template 2: Fetching Dynamic Arguments
  1. Guide

Templates

Template 1: Checking Condition

package main

import (
    "fmt"
    "time"
)

// ConditionResult represents the result of condition evaluation
type ConditionResult struct {
    Satisfied bool
    Timestamp time.Time
    Response  float64
}

// condition evaluates user-defined conditions and returns the result
func condition() ConditionResult {
    // Return the condition result
    return ConditionResult{
        Satisfied: true,
        Timestamp: time.Now(),
        Response:  0,
    }
}

func main() {
    // Call the condition function
    result := condition()

    // Print the results
    fmt.Println("Condition satisfied:", result.Satisfied)
    fmt.Println("Timestamp:", result.Timestamp.Format(time.RFC3339))
    fmt.Println("Response:", result.Response)

    if result.Response != 0 {
        fmt.Println("Response:", result.Response)
    }
}

Template 2: Fetching Dynamic Arguments

package main

import (
    "encoding/json"
    "fmt"
)

func main() {
    // Create result object with parameter name matching the function parameter name
    resultPayload := map[string]interface{}{
        "<function_parameter_name>": <value to be passed>, // Use the exact parameter name from the smart contract
    }

    jsonValue, _ := json.Marshal(resultPayload)
    fmt.Println("Payload received:", string(jsonValue))
}
PreviousFee CalculationNextUsecases

Last updated 29 days ago