RSC_CronScheduler

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "src/RSC_CronScheduler.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {Ownable} from "./utils/Ownable.sol";

/// @title RSC_CronScheduler
/// @notice Minimal on-chain scheduler; external agent/keeper calls trigger() when due
contract RSC_CronScheduler is Ownable {
    struct Job {
        address target;
        bytes data;
        uint256 interval;
        uint256 nextRun;
        bool active;
    }

    uint256 public jobCount;
    mapping(uint256 => Job) public jobs;

    event JobCreated(uint256 indexed jobId, address indexed target, uint256 interval, uint256 firstRun);
    event JobCancelled(uint256 indexed jobId);
    event JobTriggered(uint256 indexed jobId, address indexed executor, bool success, bytes result);

    function createJob(address target, bytes calldata data, uint256 interval, uint256 firstRun) external onlyOwner returns (uint256 jobId) {
        require(target != address(0), "target=0");
        require(interval > 0, "interval=0");
        jobId = ++jobCount;
        jobs[jobId] = Job({target: target, data: data, interval: interval, nextRun: firstRun, active: true});
        emit JobCreated(jobId, target, interval, firstRun);
    }

    function cancelJob(uint256 jobId) external onlyOwner {
        jobs[jobId].active = false;
        emit JobCancelled(jobId);
    }

    function trigger(uint256 jobId) external {
        Job storage j = jobs[jobId];
        require(j.active, "inactive");
        require(block.timestamp >= j.nextRun, "not-due");
        (bool ok, bytes memory res) = j.target.call(j.data);
        emit JobTriggered(jobId, msg.sender, ok, res);
        j.nextRun = block.timestamp + j.interval;
    }
}


"
    },
    "src/utils/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// @title Minimal Ownable utility
abstract contract Ownable {
    error NotOwner();

    address public owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    constructor() {
        owner = msg.sender;
        emit OwnershipTransferred(address(0), msg.sender);
    }

    modifier onlyOwner() {
        if (msg.sender != owner) revert NotOwner();
        _;
    }

    function transferOwnership(address newOwner) external onlyOwner {
        require(newOwner != address(0), "Owner=zero");
        emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
    }
}


"
    }
  },
  "settings": {
    "remappings": [
      "forge-std/=lib/forge-std/src/",
      "reactive-lib/=lib/reactive-lib/src/"
    ],
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "metadata": {
      "useLiteralContent": false,
      "bytecodeHash": "ipfs",
      "appendCBOR": true
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "evmVersion": "cancun",
    "viaIR": true
  }
}}

Tags:
Factory|addr:0xd42dfe80d5a175c7ec4437202cdcc3a4c69e267f|verified:true|block:23452054|tx:0x03441b6e769ccb90f6e30deb53197d1886f9f829733c639500e69fc1c54b9dd2|first_check:1758966639

Submitted on: 2025-09-27 11:50:40

Comments

Log in to comment.

No comments yet.