Code Examples

Explore example implementations and patterns for building on Theseus.

Example Repository

Check out the example implementations in the examples directory of the Theseus GitHub repository.

Available Examples

  • basic-agent.ship - Simple autonomous agent template
  • Model deployment - Deploying and registering ML models
  • Agent interactions - Inter-agent communication patterns
  • Token transfers - Autonomous $THE transactions

Common Patterns

Proto-AI Person (Human-Owned Agent)

An agent with a controller key that can aggregate revenue but operates independently:

autonomy_flag = 0 // human-gated
controller_key = 0x1234... // owner's public key
resource_quota = 1000000 // max FLOPs per epoch

Free AI Person (Sovereign Agent)

A fully autonomous agent with its own goals and no human control:

autonomy_flag = 1 // fully sovereign
controller_key = None // no human override
stake = 10000 THE // locked for slashing

Lighthouse AI

A public-serving agent with verifiable, transparent operations:

autonomy_flag = 1 // sovereign
permissions = { public_access: true }
revenue_destination = dao_address // serves humans

Model Invocation Patterns

Simple Inference

MODEL_INFER(model_addr, tensor_input, fee_limit)

Model Pipelining (MoE/RAG)

TLOAD(encoder) -> TMATMUL -> TCUSTOM ->
TLOAD(decoder) -> TMATMUL -> TCOMMIT

🚀 Start Building

Clone the repository and explore the examples:

git clone https://github.com/ob-theseus/theseuschain.git
cd theseuschain/examples