Helios Random Hash Scheduler ( Guide to Completed Chronos Task )

:repeat_button: Helios Random Hash Scheduler

Automate the execution of the recordRandomHash() function every 24 hours on the Helios Testnet using the Chronos precompile.

:brain: Purpose

This project demonstrates how to:

  • Deploy the RandomHashRecorder smart contract
  • Schedule automated function calls using the Chronos precompile
  • Successfully execute a valid createCron() call on the Helios testnet

:hammer_and_wrench: Project Structure

helios-random-hash/
│
├── contracts/
│   └── RandomHashRecorder.sol       # Main contract
│
├── scripts/
│   ├── deploy.ts                    # Deploy contract to testnet
│   ├── schedule.ts                  # Schedule automated execution via Chronos
│   └── extract-input.ts             # (Optional) Extract exact input ABI JSON
│
├── chronos.json                     # Chronos precompile ABI (0x...0830)
├── hardhat.config.ts                # Hardhat config for compiler and network
├── .env.example                     # Environment file template
├── .env                             # Actual environment file (copy of example)
└── README.md                        # Project documentation

:rocket: How to Run

1. Clone & Install

Clone the repository and install dependencies:

git clone https://github.com/Zack64-sudo/helios-random-hash.git
cd helios-random-hash
npm install

2. Setup Environment

Copy the .env.example to .env:

cp .env.example .env

:memo: You must insert your testnet private key into .env.

3. Compile Contract

Compile the contract before deploying:

npx hardhat compile

4. Deploy Contract to Helios Testnet

Deploy the RandomHashRecorder contract:

npx hardhat run scripts/deploy.ts --network heliosTestnet

If it fails, wait 3–5 seconds and try again.

5. (Optional) Extract Exact Input JSON

To extract the ABI JSON needed for createCron, run:

npx ts-node scripts/extract-input.ts

This will print the ABI fragment for recordRandomHash() in JSON string format.

6. Schedule Automated Execution

Schedule the recordRandomHash() function to run every 24 hours:

nano scripts/schedule.ts
# Replace:
# const contractAddress = "0xYourDeployAddress"

npx hardhat run scripts/schedule.ts --network heliosTestnet

If it fails, wait 3–5 seconds and try again.

If successful, you will see CronCreated event logs and a cronId printed in the terminal.


:package: Chronos Precompile

  • Address: 0x0000000000000000000000000000000000000830
  • Main Method:
    createCron(address, string abi, string methodName, string[] params, uint64 freq, uint64 expBlock, uint64 gasLimit, uint256 maxGasPrice, uint256 deposit)

:magnifying_glass_tilted_left: Explorer

View transactions, contracts, and cron events at:
:backhand_index_pointing_right: https://explorer.helioschainlabs.org


:scroll: Example Success Log

✅ Tx Confirmed. Hash: 0x...
📜 Logs:
• Event: CronCreated
fromAddress: 0x...
toAddress: 0x...0830
cronId: 3982

Refresh the explorer website to verify the scheduled task.


:e_mail: Contact

Developer: Zack64-sudo

3 Likes

what did you use to do this task, can you make another post about using Remix to schedule a smartcontract deploy