Plugin & Action Framework
The Plugin & Action layer turns any contract call, API request, or AI routine into a reusable building block that agents can discover and execute with one JSON payload or a direct Python import. This section explains how actions are declared, packaged, vetted, and distributed.
6.1 Action Schema
Every action is described by a concise schema—think “function signature + policy metadata.”

inputs / outputs
– fully typed for auto-validation.policy_tags
– allow runtime filters (e.g., “finance actions require CFO approval”).risk_limits
– enforced before signing; authors can embed sane defaults.
The same schema lives beside a Python or TypeScript implementation file. Tooling generates JSON Schema, Pydantic, Zod, and OpenAPI docs from a single source.
6.2 Writing a Plugin
Python Example
from degents import action, ActionCtx
@action(
schema="swap.json", # path to the JSON snippet above
gas_estimator="dex.oracle" # optional: custom gas estimator action
)
def dex_swap(ctx: ActionCtx, sell_token: str, buy_token: str,
amount_in: int, slippage_bps: int):
router = ctx.adapters.dex_router
quote = router.get_quote(sell_token, buy_token, amount_in)
assert quote.slippage_bps <= slippage_bps
tx = router.build_tx(quote)
receipt = ctx.sign_and_submit(tx)
return {"tx_hash": receipt.hash, "amount_out": receipt.amount_out}
Key points
ActionCtx
Gives access to wallet provider, adapters, and policy verdicts.
Decorator
Links code to schema; registers hot-reload watcher in dev mode.
Return dict
Auto-validated against outputs
schema and logged for audit.
TypeScript Parity
import { action } from "@degents/ts";
export const dexSwap = action(schema, async (ctx, args) => {
const quote = await ctx.adapters.dexRouter.getQuote(args);
...
});
6.3 Testing & Certification
Unit tests
pytest / vitest
must cover ≥80 % branches; run in CI.
Registry publishing
Sim sandbox
Forked chain replay; verifies gas-safety, re-entrancy guards.
Main-net enable
Static analysis
Mythril / Slither for Solidity snippets; Bandit for Python.
Certification badge
Human audit (opt.)
Community or third-party review; results on-chain.
Higher reputation tier
Passing suites sign a Certification Manifest (.cert.json
) bundled with the plugin; the registry surfaces trust scores to all agents at load-time.
6.4 Marketplace & Reputation
Registry smart contract – stores plugin hashes, versions, stake deposits, and published SBOM.
Stake-weighted rating – users upvote or flag executions; bad behaviour can slash the author’s stake.
Auto-update channels – agents can subscribe to semver ranges (^1.3) and receive signed diffs.
Revenue share – optional royalty split; when an action collects fees, proceeds flow to its stake address.
Bronze
Unit tests + CI pass
Listed in registry
Silver
Static analysis clean
Higher discovery rank
Gold
External audit + ≥90 % success ratio
Eligible for featured placement
Platinum
> 10 k daily calls + no slashes
Lower protocol fee, early API access
Takeaway
The Plugin & Action Framework lets any developer ship secure, policy-aware capabilities that agents can call instantly—whether the code lives on-chain, off-chain, or at the edge. Tight schema typing, automated certification, and a stake-based marketplace keep quality high while maintaining open participation.
Last updated