For this example, let’s say you stumble upon a mysterious Oracle contract 🔮 that displays a new random number every day. You’re unsure about the Oracle’s origin or purpose but for some reason you desperately want to know whenever it displays your favorite number. We’ve got you!

Let’s write a custom smart contract that checks the Oracle’s magic number and emits an event if it matches your favorite number:

MagicNumberChecker.sol
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.26;

import {IMysteriousOracle} from "../interfaces/IMysteriousOracle.sol";

contract MagicNumberChecker {

    IMysteriousOracle public immutable mysteriousOracle;

    event YayItsMyFavoriteNumber();

    constructor(address mysteriousOracleAddr) {
        mysteriousOracle = IMysteriousOracle(mysteriousOracleAddr);
    }

    function checkMagicNumber() external {
        uint8 magicNumber = mysteriousOracle.getMagicNumber();

        if (magicNumber == 47) {
            emit YayItsMyFavoriteNumber();
        } else {
            revert();
        }
    }
}

Now, let’s construct an Instruction to call this contract whenever on-chain conditions will allow:

  • set Instruction.action to the address of the Call Action

  • set Instruction.arguments to encoded calldata specifying:

    • set Schedule.interval to 0 so the Instruction executes as soon as your favorite number shows up

    • the address of your MagicNumberChecker contract

    • the function selector for checkMagicNumber

Now, activate this Instruction and you’ll never miss your favorite number!