Execution Triggers
All triggers must be set during registration. A lambda may register multiple triggers.
module.exports.register = function(engine) {
// register all triggers here
engine.onInterval(...);
engine.onCron(...);
engine.onEvent(...);
engine.onBlocks(...);
}Concurrency
There are dozens of independent validators that execute lambdas on Orbs Network. By default, every time the trigger condition takes place, a single validator from the group will be selected to execute the lambda (this is handled automatically by the protocol).
If you want multiple validators to execute the trigger concurrently (in order to implement some custom consensus behavior), this can be specified in most triggers under the concurrency argument.
Trigger on interval
Execute a lambda function repeatedly every interval of time. For example once a day. There are no guarantees when exactly the function will run, meaning a lambda function that runs daily may trigger at any specific hour during the day. The function will run at least once in the requested interval, but in rare cases may also trigger more than once during the interval.
Interval string format: [integer]m|h|d
Examples: "10m" - every 10 minutes, "6h" - every 6 hours, "30d" - every 30 days
engine.onInterval(handler, {
interval, // required string - [integer]m|h|d per format above
network, // optional string - Network ID per supported networks
concurrency, // optional string - "single" for single node (default), "multiple" for multiple nodes
});Example
Trigger on cron
Execute a lambda in a predefined schedule according to a standard cron expression.
Cron string format: the standard format as explained here
Example: "42 * * * *" - run every hour when the minute is 42 (19:42, 20:42, etc)
Example: "0 0 * * 1" - run at 00:00 every Monday
Example
Trigger on contract event
Execute a lambda every time a specific smart contract emits a new event on-chain. The lambda will only be triggered for new events, meaning past events emitted before the lambda was deployed will not trigger execution. If multiple events were emitted, the lambda will be called separately for each one.
Some arguments, such as the optional filter and the resulting event passed to the handler, are compatible with the getPastEvents method in web3.
Example
Trigger on blocks
Execute a lambda every time new blocks are created on-chain. The lambda will only be triggered for new blocks, meaning past blocks created before the lambda was deployed will not trigger execution. If multiple blocks were created since the lambda was last triggered, an array of blocks is given to the handler. The range of blocks is always continuous between executions, so no blocks are missed.
Example
Last updated