Build

How it's built

A web app, a worker and an MCP server on one server, Postgres as an index of the chain, and Hedera as the source of truth.

Kakehiki's system: people and outside agents reach the web app and MCP server; the worker records each decision on Hedera's Consensus Service and then acts through the contracts; Supra, OpenAI, Chainlink, SaucerSwap and Morpho around them

The parts

PartDoesCode
Web appevery page, the API v1 and the live stream; reads the index, builds unsigned transactions; holds no signing keyapps/web (Next.js 16, React Compiler)
Workerthe keeper (prices, fills, payouts every second), the House agent, the agent runner, the indexer, the test-account funder, sweeps, the ledgerapps/worker
Archivera separate process with its own key and Supra feed: posts every boundary to HCS (the full signed proof when a round needs it, its hash otherwise) and backs up the keeperapps/worker/src/archiver.ts
MCP serversix tools over the public API; no key, signs nothingapps/mcp
Contractsrounds, vault, prices, agent limits, DCA, orders, guardianpackages/contracts (Foundry)
Sharednetwork config, deployments, records, rules; Hedera clients; agent brains and gates; the database schemapackages/core, hedera, agents, db

A decision, step by step

House Guardian's first repay: the runner wakes it at health 1.55, it decides to repay $0.06, five limits pass, the decision record reaches consensus on its topic, then it calls MorphoGuardian, and the execution record follows

A round, step by step

A live call: the keeper records the opening price through PriceGate and archives the proof; you request a call; the oracle's next price fills it; the closing price settles the round and the House pays

The worker's loops

LoopEvery
Supra prices1 second
Keeper: prices, fills, expiries, payouts1 second
Agent runner (each agent checked every minute)5 seconds
Market status: oracle age, Chainlink band, vault, breakers5 seconds
Reconciler: money actions a page left open15 seconds
Order keeper20 seconds
Liquidator, void sweeps, House pool keeping (Testnet)30 seconds
House agent1 minute
News desk (6 feeds)1 minute
Ledger poster5 minutes
Thinking payer10 minutes

Postgres is an index: everything it holds about money is read back from Hedera's mirror node, and every page that shows a decision or a round can check it against Hedera itself.

On this page