Helios Random Hash Scheduler
Automate the execution of the recordRandomHash() function every 24 hours on the Helios Testnet using the Chronos precompile.
Purpose
This project demonstrates how to:
- Deploy the
RandomHashRecordersmart contract - Schedule automated function calls using the Chronos precompile
- Successfully execute a valid
createCron()call on the Helios testnet
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
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
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
CronCreatedevent logs and acronIdprinted in the terminal.
Chronos Precompile
- Address:
0x0000000000000000000000000000000000000830 - Main Method:
createCron(address, string abi, string methodName, string[] params, uint64 freq, uint64 expBlock, uint64 gasLimit, uint256 maxGasPrice, uint256 deposit)
Explorer
View transactions, contracts, and cron events at:
https://explorer.helioschainlabs.org
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.
Contact
Developer: Zack64-sudo
