How to integrate the scheduler in your move code
Contract: 0x1295ff206bb3110949b2eead14a93792ced095184828e374aa00a70e7906e24b
JarJar Scheduler Integration Guide
This guide explains how to integrate the JarJar Scheduler into your Sui Move smart contract. The JarJar Scheduler allows you to schedule task executions at specific future timestamps.
Table of Contents
Overview
JarJar Scheduler Contract
Integration Steps
Example Implementation
Best Practices
Overview
The JarJar Scheduler is a decentralized task scheduling system on the Sui blockchain. It allows you to emit events for scheduled tasks, which validators can then execute at the specified time.
JarJar Scheduler Contract
package_id: 0x1295ff206bb3110949b2eead14a93792ced095184828e374aa00a70e7906e24bThe core function you'll interact with is emit_scheduled_task_event. Here's its signature:
Parameters:
execution_path: A string describing which function to call in which module (e.g., "module::function").execution_time: The timestamp (in milliseconds) when the smart contract should be executed.amount: The amount of Binks to be given back to the validator upon execution.params_id: The address of a shared object containing information for the function executed by the scheduler.anti_spam_fee: A Binks coin used to prevent system spam (must be > 1 BINKS).
Integration Steps
Import the JarJar Scheduler module in your contract:
Create a
Paramsstruct to hold the task information:Implement a function to register scheduled tasks:
Implement the function to be executed by the scheduler:
(Optional) Implement a cancellation function:
Example Implementation
Here's an example of how to implement the JarJar Scheduler in your contract:
Best Practices
Always include sufficient fee to incentivize validators to execute your task.
Use the
Clockobject to verify the execution time in yourtask_to_executefunction.Implement proper access control for task cancellation.
Handle potential errors and edge cases in your scheduled tasks.
Consider the gas costs of your scheduled tasks to ensure they can be executed successfully.
Use meaningful and unique
execution_pathstrings to avoid conflicts with other contracts.
By following this guide, you can successfully integrate the JarJar Scheduler into your Sui Move smart contract, enabling decentralized, time-based task execution on the Sui blockchain.
Last updated