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

ConceptPanda type
Account / addressstr
Token amountint (base units)
Model weightsdict (serialized via panda.ml.save_model())
Task inputlist (feature vectors)
Inference outputlist (predictions)
State-changing@call
Read-only@query
Errorsraise

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_dict MUST be produced by panda.ml.save_model() and contain a __panda_ml_model__ key. task_price is the cost per task in base token units (0 for free agents).

Calls

  • submit_task(ctx, input_data: list) -> int Submits a task. The agent runs inference immediately and stores the result. Returns the task_id. MUST emit TaskCompleted.

  • update_model(ctx, new_model_dict: dict) Replaces the agent's model. Caller MUST be the owner. MUST emit ModelUpdated. The model_version counter 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) -> dict Returns {task_id, input_data, output, submitter, block_height} for a completed task.

  • predict(input_data: list) -> list Stateless inference (does not create a task record). Free to call.

  • agent_info() -> dict Returns {name, description, model_type, model_version, task_price, tasks_completed, owner}.

  • task_count() -> int Total tasks completed.

Events

TaskCompleted

MUST fire when a task is submitted and inference completes.

  • task_id: int
  • submitter: str
  • model_type: str

ModelUpdated

MUST fire when the model weights are replaced.

  • model_version: int
  • model_type: str
  • updater: str

Notes

  • Verifiability: Every submit_task transaction produces an ExecutionReceipt. 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.