Search
K
Comment on page

Cron triggers

Trigger actions to check contract state at specific intervals
Cron triggers define the time intervals through a cron object with two fields:
  • timezone: the + or - hours in relation to UCT
  • rule: a temporal definition using the standard unix cron job syntax

Rule definition

Field
Description
Minutes
Accepts values between 0 and 59
Hours
Accepts values between 0 and 23
Day
Accepts values between 0 and 31
Month
Accepts values between 0(= none) and 12(= December)
Weekday
Accepts values between 0(= Sunday) and 7(= Sunday)
In each field you can define time conditions by using those operators:
Operator
Description
*
Every value for the field
/
Step (eg. */5 in the minute field will trigger every 5 minutes)
,
List separator (eg. */5,*/2 in the minute field will trigger every 5 and every 2 minutes)
-
Range separator (eg. 2-4 in the minute field will trigger every hour at minute 2, 3 and 4)

Examples

Create a cron trigger

Query
Result
mutation {
createCronTrigger(input: {
name: "HELLO CRON",
type: CronTrigger,
statement: {
cron: {
rule: "*/2 * * * *"
timezone: "-0000"
}
contract: {
address: "0xeead394A017b8428E2D5a976a054F303F78f3c0C",
abi: [
{
inputs: [
{
internalType: "contract IConverterAnchor",
name: "_poolAnchor",
type: "address"
}
],
name: "poolAvailableSpace",
outputs: [
{
internalType: "uint256",
name: "poolAvailableSpace-0",
type: "uint256"
},
{
internalType: "uint256",
name: "poolAvailableSpace-1",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
}
]
},
inputs: [
{
type: "address",
name: "_poolAnchor",
value: "0x8b3082e273E4B923830c637a203c1C1D963cA307"
},
],
method: {
name: "poolAvailableSpace"
}
},
actions: [
{
type: Webhook,
attributes: {
uri: "http://www.dasa"
}
}
]
}) {
UUID
}
}
{
"data": {
"createCronTrigger": {
"UUID": "5b2d1664-8215-4910-9186-241a8f8385f9"
}
}
}

Last modified 2yr ago