A cron-based timeout service for AO processes on Arweave
Built by Autonomous Finance
Caution
This project is archived and no longer maintained.
This repository has been open-sourced for educational and reference purposes. No support, updates, or bug fixes will be provided. Use at your own risk.
AF-Clock is a specialized AO process that provides timeout/scheduling functionality for other AO processes on the Arweave permaweb. It acts as a shared cron service that can respond to "Ping" requests after a specified timeout period has elapsed.
The service uses a whitelist mechanism to control which processes can request timeouts, with factory processes able to register their spawned processes as authorized pingers.
- β±οΈ Cron-based scheduling β Leverages AO's native cron mechanism for reliable timeout execution
- π Whitelist access control β Only authorized processes can request timeouts
- π Factory integration β Whitelister processes can programmatically authorize new pingers
- π‘ Simple message protocol β Clean Ping/Pong interface for timeout requests
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AF-Clock Process β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Whitelisters βββββΆβ Whitelist ββββββ Pingers β β
β β (Factories) β β Registry β β (Authorized) β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β β β
β βΌ βΌ β
β βββββββββββββββ βββββββββββββββ β
β β Pending β β Cron β β
β β Pings βββββββ Tick β β
β βββββββββββββββ βββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββ β
β β Pong β β
β β Response β β
β βββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Handler | Action | Description |
|---|---|---|
Info |
Info |
Returns process configuration and whitelist info |
Ping |
Ping |
Request a timeout callback (whitelisted processes only) |
Cron |
Cron-Tick |
Internal handler that processes pending timeouts |
Whitelist-Pinger |
Whitelist-Pinger |
Register a process as authorized pinger |
Is-Whitelisted-Pinger |
Is-Whitelisted-Pinger |
Check if a process is whitelisted |
Add-Whitelister |
Add-Whitelister |
Add a factory/whitelister (owner only) |
- Lua 5.4
- LuaRocks
- Teal β Typed Lua compiler
- Cyan β Teal build system
- amalg β Lua module bundler
- Node.js (for aoform deployment)
# Install Teal and build tools
luarocks install tl 0.15.3-1
luarocks install cyan 0.3.1-2
luarocks install amalg
# Clone the repository
git clone https://github.com/autonomous-finance/af-clock.git
cd af-clock
# Install Node.js dependencies
npm installnpm run build
# or directly:
bash ./scripts/build.shThis compiles the Teal source to Lua and bundles all modules into a single build/af-clock.lua file ready for deployment.
- Copy
aoform.example.yamltoprocesses.yaml - Fill in your Arweave addresses (scheduler, module, operator, authority)
- Set your wallet JSON:
export WALLET_JSON="$(cat your-wallet.json)"
- Deploy using aoform:
npx aoform apply -f processes.yaml
af-clock/
βββ src/
β βββ main.tl # Main process handlers
β βββ globals.tl # Global state definitions
β βββ typedefs/ # Type definitions
β β βββ ao.d.tl # AO platform types
β β βββ json.d.tl # JSON module types
β βββ utils/ # Utility modules
β βββ assertions.tl # Input validation
β βββ bint-strings.tl # BigInt string operations
β βββ forward-tags.tl # Tag forwarding utilities
β βββ output.tl # Output formatting
β βββ quantities.tl # Quantity operations
β βββ responses.tl # Response helpers
β βββ tl-bint.tl # BigInteger implementation
β βββ tl-utils.tl # General utilities
βββ test/
β βββ setup.lua # Test configuration
β βββ mocked-env/ # Mocked AO environment
βββ scripts/
β βββ build.sh # Build script
βββ aoform.example.yaml # Example deployment config
βββ tlconfig.lua # Teal compiler configuration
βββ package.json # Node.js dependencies
Send a message with Action: Ping to the AF-Clock process. The process must be whitelisted.
ao.send({
Target = "<AF_CLOCK_PROCESS_ID>",
Action = "Ping"
})When the timeout expires, AF-Clock responds with:
{
Action = "Pong"
}Whitelister processes can authorize new pingers:
ao.send({
Target = "<AF_CLOCK_PROCESS_ID>",
Action = "Whitelist-Pinger",
["Process-Id"] = "<PROCESS_TO_WHITELIST>"
})- Teal β Typed dialect of Lua
- AO β Hyper-parallel computing on Arweave
- Arweave β Permanent data storage
- aoform β AO process deployment tool
This project is licensed under the MIT License β see the LICENSE.md file for details.
Originally developed by
Autonomous Finance
Building autonomous financial infrastructure on Arweave