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

  1. Overview

  2. JarJar Scheduler Contract

  3. Integration Steps

  4. Example Implementation

  5. 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: 0x1295ff206bb3110949b2eead14a93792ced095184828e374aa00a70e7906e24b

The 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

  1. Import the JarJar Scheduler module in your contract:

  2. Create a Params struct to hold the task information:

  3. Implement a function to register scheduled tasks:

  4. Implement the function to be executed by the scheduler:

  5. (Optional) Implement a cancellation function:

Example Implementation

Here's an example of how to implement the JarJar Scheduler in your contract:

Best Practices

  1. Always include sufficient fee to incentivize validators to execute your task.

  2. Use the Clock object to verify the execution time in your task_to_execute function.

  3. Implement proper access control for task cancellation.

  4. Handle potential errors and edge cases in your scheduled tasks.

  5. Consider the gas costs of your scheduled tasks to ensure they can be executed successfully.

  6. Use meaningful and unique execution_path strings 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