Agents that schedule themselves. Run forever. No babysitter.
On other chains, an “agent” needs an off-chain script keeping it alive. On Asentum, the agent IS the contract. It holds its own funds. It schedules its own next thought via cron. It runs forever, fired by consensus itself. Kill the server, the agent keeps going.
An agent is a contract that re-schedules itself.
// DCAAgent — a persistent, autonomous on-chain agent for AsentumChain.
//
// The pitch: on other chains an "agent" needs an off-chain script keeping
// it alive (a Lambda, a cron container, a laptop that must stay awake). On
// Asentum the agent IS the contract. It holds its own state, and the chain's
// own cron registry (ARC-21, system contract 0x…06) wakes it on a schedule —
// fired by consensus itself. Kill every server on earth; the agent keeps
// thinking, one `tick()` at a time, for as long as its gas escrow lasts.
//
// tick() is the agent's reasoning loop: observe → decide → act → (the cron
// registry) reschedules the next wake-up automatically. This reference agent
// keeps a heartbeat (tick count + last-seen block/time) so its liveness is
// visible on-chain; swap the body of tick() for any autonomous behaviour —
// a DCA buy on AuraSwap, a treasury rebalance, an oracle push.
//
// Wiring (the REAL cron API — note: absolute MILLISECOND timestamps, and
// cron is funded by a separate tx's value, since cross-contract calls don't
// forward value):
//
// 1. deploy this source (tx.to = 0x0…0, data = source)
// 2. agent.init() (one-shot)
// 3. cron.schedule(agent, 'tick', [], nextRunAtMs, intervalMs, 0, gasLimit)
// on 0x…06, with tx.value = gas escrow <- this is what makes it persistent
//
// chain.blockTimestamp is in MILLISECONDS on AsentumChain.
({
// One-shot at deploy. Records the agent's birth block.
init() {
assert(!storage.get('born'), 'already initialised');
storage.set('born', chain.blockNumber.toString());
storage.set('ticks', '0');
emit('AgentBorn', { block: chain.blockNumber.toString(), ts: chain.blockTimestamp.toString() });
return true;
},
// The agent's reasoning loop — called by the cron registry on schedule.
// Observe (block/time), decide + act (here: bump the heartbeat), and the
// cron registry handles rescheduling the next wake-up. Open to any caller
// so the chain's cron (msg.sender = 0x0…0) can fire it; on mainnet you'd
// gate to the cron caller.
tick() {
const n = (BigInt(storage.get('ticks') || '0') + 1n).toString();
storage.set('ticks', n);
storage.set('lastBlock', chain.blockNumber.toString());
storage.set('lastTs', chain.blockTimestamp.toString());
emit('AgentTick', { n, block: chain.blockNumber.toString(), ts: chain.blockTimestamp.toString() });
return n;
},
// ── views ───────────────────────────────────────────────────────────
ticks() { return storage.get('ticks') || '0'; },
status() {
return {
born: storage.get('born') || null,
ticks: storage.get('ticks') || '0',
lastBlock: storage.get('lastBlock') || null,
lastTs: storage.get('lastTs') || null,
};
},
});tick() is the agent's reasoning loop. It runs, decides whether to act, then schedules its own next call. The chain itself is the runtime — no Lambda, no cron container, no “is the bot still alive?” check. The contract is the agent.
Deploy the agent contract.
init() registers the first cron call. From this block forward, the chain itself will wake the agent on schedule.
Send it a budget.
The agent holds its own funds. No wallet keys to manage, no hot wallet to keep refilled. The agent is the wallet.
It runs forever, on its own.
Cron fires tick(). The agent observes, decides, acts, schedules its next wake-up. Run for years. No server, no babysitter.
Every “AI agent” in crypto today is actually a script on someone's laptop.
No Lambda function timing out. No EC2 instance to keep running. No cron job dying when your laptop sleeps. The chain is the substrate.
The agent IS the wallet. No hot key to protect, no signer to refill, no “the bot ran out of gas” failure mode.
The agent's logic is on-chain JavaScript. Anyone can read what it will do. No black-box bot you have to trust.
Agent A calls agent B calls oracle C. All on-chain. All atomic. All replayable. No microservice handshakes.
No cloud provider can shut your agent off. No API key to revoke. It runs for as long as the chain runs.
No server bill. No Vercel. No Render. The validators do the compute as part of consensus. Storage is your only ongoing cost.
Eight kinds of agent on one pattern.
Same shape: tick() observes, decides, acts, re-schedules. Swap the body for any autonomous behavior.
DCA botBuys a target token on schedule, forever, without you.
RebalancerWatches a portfolio, swaps back to target ratios.
LiquidatorMonitors lending positions, liquidates underwater loans.
Arbitrage agentDiffs prices across DEXs, captures profit on cycles.
Moderation botReads on-chain content, hides flagged posts via state.
Treasury sweepDrains incoming revenue into yield each block.
LLM gatewayHolds prepaid quota, fans inference requests to providers.
Game NPCOn-chain character that acts in response to player state.
Read the contract on GitHub.
This agent is deployed and ticking on testnet right now, woken by ARC-21 cron.
Cron is the agent runtime.
Every persistent agent uses ARC-21 cron. The same ARC-21 cron primitive subs.asentum.com uses.
Cross-contract calls explained.
E(ADDR) is how agents talk to oracles, DEXs, and each other. Hardened JavaScript blocks reentrancy structurally.
Five more dapps demonstrating what the chain unlocks.
Recurring charges fired by the chain.
Open showcase →Royalty splitsRevenue splits that auto-distribute.
Open showcase →SubscriptionsRecurring billing, charged by the protocol.
Open showcase →Creator economyBorderless tipping + memberships.
Open showcase →TreasuryDCA, rebalance, sweep on autopilot.
Open showcase →SocialOn-chain profiles, posts, comments.
Open showcase →