Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.

Autonomous-Finance/af-clock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Archived MIT License AO / Arweave Teal

⏰ AF-Clock

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.


πŸ“– Overview

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.

Key Features

  • ⏱️ 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

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         AF-Clock Process                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                  β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
β”‚   β”‚  Whitelisters │───▢│  Whitelist   │◀───│   Pingers    β”‚      β”‚
β”‚   β”‚  (Factories)  β”‚    β”‚   Registry   β”‚    β”‚ (Authorized) β”‚      β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚
β”‚                              β”‚                    β”‚              β”‚
β”‚                              β–Ό                    β–Ό              β”‚
β”‚                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚
β”‚                       β”‚   Pending   β”‚     β”‚    Cron     β”‚       β”‚
β”‚                       β”‚    Pings    │◀────│    Tick     β”‚       β”‚
β”‚                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β”‚                              β”‚                                   β”‚
β”‚                              β–Ό                                   β”‚
β”‚                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                           β”‚
β”‚                       β”‚    Pong     β”‚                           β”‚
β”‚                       β”‚  Response   β”‚                           β”‚
β”‚                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                           β”‚
β”‚                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Message Handlers

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)

πŸš€ Getting Started

Prerequisites

Installation

# 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 install

Building

npm run build
# or directly:
bash ./scripts/build.sh

This compiles the Teal source to Lua and bundles all modules into a single build/af-clock.lua file ready for deployment.

Deployment

  1. Copy aoform.example.yaml to processes.yaml
  2. Fill in your Arweave addresses (scheduler, module, operator, authority)
  3. Set your wallet JSON:
    export WALLET_JSON="$(cat your-wallet.json)"
  4. Deploy using aoform:
    npx aoform apply -f processes.yaml

πŸ“ Project Structure

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

πŸ’¬ Message Protocol

Requesting a Timeout (Ping)

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"
}

Whitelisting a Process

Whitelister processes can authorize new pingers:

ao.send({
  Target = "<AF_CLOCK_PROCESS_ID>",
  Action = "Whitelist-Pinger",
  ["Process-Id"] = "<PROCESS_TO_WHITELIST>"
})

πŸ› οΈ Technology Stack

  • Teal β€” Typed dialect of Lua
  • AO β€” Hyper-parallel computing on Arweave
  • Arweave β€” Permanent data storage
  • aoform β€” AO process deployment tool

πŸ“œ License

This project is licensed under the MIT License β€” see the LICENSE.md file for details.


πŸ™ Attribution

Originally developed by
Autonomous Finance

Building autonomous financial infrastructure on Arweave


⚠️ This repository is archived. No issues or pull requests will be addressed.

About

No description, website, or topics provided.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors