Chronos Deploy Remix & Termux Helios Steps

Create a Smart Contract in Remix

  1. Create a file named CronCounter.sol and enter the following code:

→ solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract CronCounter {

address public owner;
uint256 public counter;
uint256 public lastCalled;

event Ticked(address indexed caller, uint256 newCounter, uint256 timestamp);

modifier onlyOwner() {
    require(msg.sender == owner, "Not owner");
    _;
}

constructor() {
    owner = msg.sender;
}

function tick() public onlyOwner {
    counter += 1;
    lastCalled = block.timestamp;
    emit Ticked(msg.sender, counter, lastCalled);
}

function getInfo() public view returns (uint256, uint256) {
    return (counter, lastCalled);
}

}


  1. Compile Contract
    In the “Solidity Compiler” tab
    Select version 0.8.x
    Click Compile

  2. Deploy Contract
    In the “Deploy & Run Transactions” tab
    Select Injected Provider - MetaMask
    Click Deploy
    Note the deployed address (it will be used in the JavaScript script)

Guide to Running Helios Cron Script in Termux (Android)

  1. Install Termux from Official Sources

:warning: Don’t install from the Play Store, use it from:

F-Droid: Termux | F-Droid - Free and Open Source Android App Repository
Or from GitHub Termux APK

  1. Update & Install Node.js

→ bash

pkg update && pkg upgrade
pkg install nodejs

Verification:

→ bash

node -v
npm -v

The Node.js version (v18+) and NPM should be displayed.

  1. Create a Cron Script Folder and File

→ bash

mkdir helios-cron
cd helios-cron
nano cron-counter.js

The nano editor will open in Termux.
Paste the JavaScript code (cron-counter.js) into nano. For example:

→ js

const { ethers } = require(“ethers”);

// Replace this:
const TARGET_CONTRACT = “0xYourContractAddressHere”;
const PRIVATE_KEY = “0xYourPrivateKeyHere”;

// Leave the rest as shown…

Once finished, press:
CTRL + O → Enter (to save)
CTRL + X (to exit)

  1. Install ethers.js Library

→ bash

npm init -y
npm install ethers

Run the Script

Make sure you’ve replaced:
0xYourContractAddressHere → your contract address
0xYourPrivateKeyHere → the private key from your Helios testnet wallet

Then run:

→ bash

node cron-counter.js

If successful, the output should look like:

:incoming_envelope: TX Hash: 0x…
:white_check_mark: Cron job registered!

Code : cron-counter.js


const { ethers } = require(“ethers”);

const TARGET_CONTRACT = “0xYourContractAddressHere”; // Ganti dgn alamat kontrakmu
const PRIVATE_KEY = “0xYourPrivateKeyHere”; // Ganti dgn private key kamu

const provider = new ethers.JsonRpcProvider(“https://testnet1.helioschainlabs.org”);
const wallet = new ethers.Wallet(PRIVATE_KEY, provider);

const CRON_ADDRESS = “0x0000000000000000000000000000000000000830”; // Alamat precompile Cron

const targetAbi = JSON.stringify([
{ name: “tick”, type: “function”, inputs: , outputs: , stateMutability: “nonpayable” }
]);

const cronAbi = [
{
inputs: [
{ internalType: “address”, name: “contractAddress”, type: “address” },
{ internalType: “string”, name: “abi”, type: “string” },
{ internalType: “string”, name: “methodName”, type: “string” },
{ internalType: “string”, name: “params”, type: “string” },
{ internalType: “uint64”, name: “frequency”, type: “uint64” },
{ internalType: “uint64”, name: “expirationBlock”, type: “uint64” },
{ internalType: “uint64”, name: “gasLimit”, type: “uint64” },
{ internalType: “uint256”, name: “maxGasPrice”, type: “uint256” },
{ internalType: “uint256”, name: “amountToDeposit”, type: “uint256” }
],
name: “createCron”,
outputs: [{ internalType: “bool”, name: “success”, type: “bool” }],
stateMutability: “nonpayable”,
type: “function”
}
];

async function main() {
const contract = new ethers.Contract(CRON_ADDRESS, cronAbi, wallet);
const currentBlock = await provider.getBlockNumber();

const frequency = 300; // setiap 300 blok (≈ 60 menit)
const expiration = currentBlock + 201600; // berlaku selama 2 minggu
const gasLimit = 300_000;
const gasPrice = ethers.parseUnits(“2”, “gwei”);
const deposit = ethers.parseEther(“0.02”);

const tx = await contract.createCron(
TARGET_CONTRACT,
targetAbi,
“tick”,
,
frequency,
expiration,
gasLimit,
gasPrice,
deposit,
{
gasLimit: gasLimit + 50_000,
gasPrice
}
);

console.log(“:incoming_envelope: TX Hash:”, tx.hash);
await tx.wait();
console.log(“:white_check_mark: Cron job registered!”);
}

main().catch(console.error);

1 Like

Thanks for your details. It’s easy to do for no-experience, but after that i still got no more XP :joy: I dont know why

2 Likes

If you mean chronos, I’m currently investigating it, sometimes I succeed and sometimes I don’t. But if I deploy the contract, I don’t think there will be any problems.