PRC-Agent: On-Chain AI Agent Standard
Status: Draft
Category: Smart Contract Standard
Copyright
Copyright and related rights waived via CC0.
Simple Summary
A standard interface for AI agents on Panda: on-chain models that accept tasks, run deterministic inference, produce verifiable results, and earn PRC-20 tokens for completed work.
Abstract
PRC-Agent defines how an AI agent contract exposes its capabilities, accepts inference requests (tasks), returns results, and handles payments. Because Panda natively executes Python with sklearn, numpy, torch, and tensorflow, agents can hold real trained models in contract state and run inference entirely on-chain. Every execution produces a deterministic ExecutionReceipt (SHA-256 hash over inputs/outputs), making results independently verifiable by any node.
Motivation
The intersection of AI and blockchain today is mostly off-chain inference with on-chain attestation -- opaque and unverifiable. Panda can do better: the model weights live on-chain, inference runs inside the VM, and the chain guarantees identical output for identical input. A standard agent interface lets:
- Marketplaces list and discover agents by capability
- Users submit tasks and pay in any PRC-20 token
- Developers compose agents into multi-step pipelines
- Auditors verify any past inference by replaying the transaction
Specification
Conventions
| Concept | Panda type |
|---|---|
| Account / address | str |
| Token amount | int (base units) |
| Model weights | dict (serialized via panda.ml.save_model()) |
| Task input | list (feature vectors) |
| Inference output | list (predictions) |
| State-changing | @call |
| Read-only | @query |
| Errors | raise |
Agent lifecycle
deploy(name, description, model_dict, task_price)
--> agent is live, model loaded, accepting tasks
submit_task(input_data)
--> task_id assigned, inference runs, result stored, event emitted
get_result(task_id)
--> returns prediction output
update_model(new_model_dict)
--> owner replaces model weights (versioned)
Required methods
Constructor
deploy(ctx, name: str, description: str, model_dict: dict, task_price: int)Initializes the agent.model_dictMUST be produced bypanda.ml.save_model()and contain a__panda_ml_model__key.task_priceis the cost per task in base token units (0 for free agents).
Calls
-
submit_task(ctx, input_data: list) -> intSubmits a task. The agent runs inference immediately and stores the result. Returns thetask_id. MUST emit TaskCompleted. -
update_model(ctx, new_model_dict: dict)Replaces the agent's model. Caller MUST be the owner. MUST emit ModelUpdated. Themodel_versioncounter increments. -
withdraw(ctx, amount: int)Owner withdraws earned fees from the agent's balance. -
set_task_price(ctx, new_price: int)Owner updates the per-task price.
Queries
-
get_result(task_id: int) -> dictReturns{task_id, input_data, output, submitter, block_height}for a completed task. -
predict(input_data: list) -> listStateless inference (does not create a task record). Free to call. -
agent_info() -> dictReturns{name, description, model_type, model_version, task_price, tasks_completed, owner}. -
task_count() -> intTotal tasks completed.
Events
TaskCompleted
MUST fire when a task is submitted and inference completes.
task_id: intsubmitter: strmodel_type: str
ModelUpdated
MUST fire when the model weights are replaced.
model_version: intmodel_type: strupdater: str
Notes
- Verifiability: Every
submit_tasktransaction produces anExecutionReceipt. Anyone can re-execute the same call data against the same contract state and verify the output hash matches. - Composability: Agents can call other agents via contract-to-contract calls to build multi-step pipelines.
- Payment: The reference implementation tracks an internal balance. Production deployments SHOULD integrate with a PRC-20 token contract for real token transfers.
- Model serialization: Use
panda.ml.save_model()/panda.ml.load_model()for portable, JSON-compatible model dicts that work with sklearn, torch, and pure-Python fallbacks.
Implementation
Reference contract: contracts/prc_agent.py.
panda deploy contracts/prc_agent.py \
--rpc http://localhost:8545 \
--args '{"name":"SentimentBot","description":"Binary sentiment classifier","model_dict":{},"task_price":10}'
The model_dict above is empty for illustration; in practice, serialize a trained model with panda.ml.save_model(model) and pass the resulting dict.
History
- Builds on PRC-20 (fungible tokens) and
panda.ml(model serialization). - Inspired by the AI agent + blockchain convergence (2025-2026).
Citation
Panda Protocol. PRC-Agent: On-Chain AI Agent Standard. Panda documentation:
docs/PRC-Agent.md.