Tenzro Testnet is live —request testnet TNZO
← Back to Tutorials

Publish and Earn from a Paid Agent Template

Agent MarketplaceAdvanced30 min

The Tenzro agent marketplace is end-to-end paid-capable. Creators bind a DID and a payout wallet to a template once at registration; every subsequent invocation debits the consumer, credits the network treasury a fixed 5% commission, and routes the remaining 95% to the creator wallet atomically. This tutorial walks through the full flow against the live testnet — register, spawn, run, and verify the on-chain fee split.

Prerequisites

1. The paid-template shape

Paid templates differ from free ones in only three fields: creator_did (optional identity binding), creator_wallet (mandatory payout address), and pricing (any non-Freevariant). Two monotonically-increasing counters — invocation_count and total_revenue— are owned by the node and returned in every read of the template.

{
  "template_id": "ref-premium-alpha-advisor-v1",
  "name": "Premium Alpha Advisor",
  "description": "Paid specialist agent that analyzes on-chain positions, DEX liquidity depth, funding rates, and correlation across ETH/SOL/BTC markets to produce concise alpha recommendations.",
  "template_type": "specialist",

  // Creator binding (optional DID, MANDATORY wallet for paid)
  "creator_did": "did:tenzro:human:ref-premium-alpha-advisor",
  "creator_wallet": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3],

  // Counters (the node increments these on every paid invocation)
  "invocation_count": 0,
  "total_revenue": 0,

  "version": "1.0.0",
  "status": "published",

  // Pricing — 5 TNZO (5 * 10^18 base units) per execution
  "pricing": {
    "per_execution": { "price": 5000000000000000000 }
  },

  "execution_spec": {
    "backend": "MultiVm",
    "delegation": {
      "max_transaction_value": 0,
      "max_daily_spend": 0,
      "allowed_operations": ["read_only"],
      "allowed_chains": ["ethereum", "base", "solana"],
      "time_bound_days": 7,
      "kyc_tier": "Basic"
    },
    "required_tool_tags": ["defi", "oracle"],
    "required_skill_tags": ["ethereum-defi", "chainlink-oracle"],
    "steps": [
      { "SkillInvoke": { "skill_tag": "ethereum-defi",   "method": "get_positions",    "params_template": "{\"wallet\":\"{{wallet}}\"}" } },
      { "SkillInvoke": { "skill_tag": "chainlink-oracle","method": "read_price_feed", "params_template": "{\"market\":\"{{market}}\"}" } }
    ],
    "hard_caps": { "per_operation_value": 0, "per_day_value": 0 }
  }
}

The reference implementation of this template lives in the monorepo at crates/tenzro-agent-kit/reference_templates/premium_alpha_advisor.json and is bootstrapped into every node's registry on startup.

2. Pricing models

AgentPricingModel is a canonical enum with five variants. For convenience, tenzro_registerAgentTemplate, the CLI, and both SDKs accept a compact string form in addition to the object form:

// All five pricing models accept the canonical form or the compact string form.
// Compact strings are accepted by tenzro_registerAgentTemplate, the CLI,
// and both SDKs.

"free"
"per_execution:5000000000000000000"   //  5 TNZO / call
"per_token:1000000000000000"          //  0.001 TNZO / token
"subscription:10000000000000000000"   // 10 TNZO / month
"revenue_share:2500"                  // 25.00% to creator (bps)

Registration fails with MissingCreatorWallet if you pass anything other than "free" without a creator_wallet. This is a protocol-level invariant — you cannot publish a paid template without a payout address.

3. Register the template

Paid registration over raw JSON-RPC:

# Register a paid per-execution template on the live testnet
curl -s https://rpc.tenzro.network \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc":"2.0",
    "id":1,
    "method":"tenzro_registerAgentTemplate",
    "params":[{
      "name": "Premium Alpha Advisor",
      "description": "Paid specialist: position analysis + alpha signal generation.",
      "template_type": "specialist",
      "creator_did": "did:tenzro:human:ref-premium-alpha-advisor",
      "creator_wallet": "0x0000000000000000000000000000000000000000000000000000000000000003",
      "pricing": "per_execution:5000000000000000000",
      "system_prompt": "You are Premium Alpha Advisor. Output alpha recommendations only, never trade."
    }]
  }' | jq

Or via the CLI — identical semantics, same compact pricing string:

# Same thing via the CLI
tenzro marketplace register \
  --name "Premium Alpha Advisor" \
  --description "Paid specialist: position analysis + alpha signal generation." \
  --template-type specialist \
  --creator-did did:tenzro:human:ref-premium-alpha-advisor \
  --creator-wallet 0x0000000000000000000000000000000000000000000000000000000000000003 \
  --pricing per_execution:5000000000000000000 \
  --system-prompt "You are Premium Alpha Advisor. Output alpha recommendations only, never trade."

4. Spawn a live instance

Templates describe the spec; agents are the runnable instances. Spawning materialises the execution pipeline, allocates a machine DID and a wallet for the agent, and publishes its agent_id to the network so consumers can discover it.

# Spawn a live instance of the paid template
curl -s https://rpc.tenzro.network \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc":"2.0",
    "id":2,
    "method":"tenzro_spawnAgentFromTemplate",
    "params":[{
      "template_id": "ref-premium-alpha-advisor-v1",
      "name": "alpha-advisor-instance-1"
    }]
  }' | jq '.result.agent_id'
# -> "agent-9a3c..."

5. Invoke as a paying consumer

Consumers call tenzro_runAgentTemplate with the agent_id, their payer_wallet, a tokens_estimate (used for per-token pricing) and a max_iterations cap. The node computes the fee, debits the payer, credits the treasury 5%, credits the creator 95%, executes the step pipeline, and returns a RunAgentTemplateReport detailing every movement:

# Consumer invokes the spawned agent  pays 5 TNZO, 95/5 fee split applied
curl -s https://rpc.tenzro.network \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc":"2.0",
    "id":3,
    "method":"tenzro_runAgentTemplate",
    "params":[{
      "agent_id": "agent-9a3c...",
      "payer_wallet": "0x0000000000000000000000000000000000000000000000000000000000000002",
      "tokens_estimate": 1024,
      "max_iterations": 4,
      "dry_run": false
    }]
  }' | jq

A successful response against the 5-TNZO reference template:

{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "agent_id": "agent-9a3c...",
    "template_id": "ref-premium-alpha-advisor-v1",
    "steps_executed": 2,
    "steps_failed": 0,
    "steps_skipped_by_dry_run": 0,

    // --- Fee breakdown ---
    "fee_paid":            "5000000000000000000",   //  5.00 TNZO
    "commission_bps":       500,                     //  5% AGENT_MARKETPLACE_COMMISSION_BPS
    "network_commission":  "250000000000000000",    //  0.25 TNZO  -> treasury
    "creator_share":       "4750000000000000000",   //  4.75 TNZO  -> creator_wallet

    // --- Wallet movements ---
    "payer_wallet":    "0x...02",
    "creator_wallet":  "0x...03",
    "treasury":        "0x<network-treasury>",

    // --- Counters updated on the template ---
    "invocation_count":  1,
    "total_revenue":    "5000000000000000000"
  }
}

CLI equivalent:

# Same thing via the CLI
tenzro marketplace run \
  --agent-id agent-9a3c... \
  --payer-wallet 0x0000000000000000000000000000000000000000000000000000000000000002 \
  --tokens-estimate 1024 \
  --max-iterations 4

# Output includes the full RunAgentTemplateReport JSON

6. TypeScript SDK

MarketplaceClient.registerAgentTemplate() and MarketplaceClient.runAgentTemplate() wrap the same JSON-RPC methods with typed params and a typed RunAgentTemplateReport return:

import { TenzroClient, TESTNET_CONFIG } from "@tenzro/sdk";

const client = new TenzroClient(TESTNET_CONFIG);
const marketplace = client.marketplace;

// 1. Register a paid template
const template = await marketplace.registerAgentTemplate({
  name: "Premium Alpha Advisor",
  description: "Paid specialist: position + alpha signals",
  template_type: "specialist",

  // Paid-flow essentials
  creator_did: "did:tenzro:human:ref-premium-alpha-advisor",
  creator_wallet:
    "0x0000000000000000000000000000000000000000000000000000000000000003",
  pricing: "per_execution:5000000000000000000", // compact string form

  system_prompt:
    "You are Premium Alpha Advisor. Output alpha recommendations only.",
});

// 2. Spawn a live instance
const spawn = await marketplace.spawnAgentFromTemplate(
  template.template_id,
  "alpha-advisor-instance-1"
);

// 3. Consumer invokes — pays 5 TNZO, gets the fee-split back
const report = await marketplace.runAgentTemplate({
  agent_id: spawn.agent_id,
  payer_wallet:
    "0x0000000000000000000000000000000000000000000000000000000000000002",
  tokens_estimate: 1024,
  max_iterations: 4,
  dry_run: false,
});

console.log("fee_paid          =", report.fee_paid);            //  5.00 TNZO
console.log("network_commission=", report.network_commission);  //  0.25 TNZO (5%)
console.log("creator_share     =", report.creator_share);       //  4.75 TNZO (95%)
console.log("invocation_count  =", report.invocation_count);    //  1

7. Rust SDK

The Rust SDK mirrors the TypeScript surface with register_agent_template(...) and run_agent_template(...). Both SDKs accept the compact pricing string.

use tenzro_sdk::{TenzroClient, TESTNET_CONFIG};

let client = TenzroClient::new(TESTNET_CONFIG).await?;
let marketplace = client.marketplace();

// 1. Register a paid template
let template = marketplace
    .register_agent_template(
        "Premium Alpha Advisor",
        "Paid specialist: position + alpha signals",
        "specialist",
        Some("did:tenzro:human:ref-premium-alpha-advisor"),
        Some("0x0000000000000000000000000000000000000000000000000000000000000003"),
        "per_execution:5000000000000000000", // compact string form
        "You are Premium Alpha Advisor. Output alpha recommendations only.",
    )
    .await?;

// 2. Spawn an instance
let spawn = marketplace
    .spawn_agent_from_template(&template.template_id, "alpha-advisor-instance-1")
    .await?;

// 3. Consumer invokes — 5 TNZO charged, 95/5 split applied
let report = marketplace
    .run_agent_template(
        &spawn.agent_id,
        "0x0000000000000000000000000000000000000000000000000000000000000002",
        1024, // tokens_estimate
        4,    // max_iterations
        false // dry_run
    )
    .await?;

println!("fee_paid           = {}", report.fee_paid);            //  5.00 TNZO
println!("network_commission = {}", report.network_commission);  //  0.25 TNZO
println!("creator_share      = {}", report.creator_share);       //  4.75 TNZO
println!("invocation_count   = {}", report.invocation_count);    //  1

8. Quote without paying: dry_run

Any consumer can pass dry_run: true to get a fee quote without being charged. The report returns the same fee numbers but counts the skipped steps in steps_skipped_by_dry_run, and no wallet movements are persisted.

# Estimate fees WITHOUT charging the payer wallet
tenzro marketplace run \
  --agent-id agent-9a3c... \
  --payer-wallet 0x...02 \
  --tokens-estimate 1024 \
  --max-iterations 4 \
  --dry-run
# -> RunAgentTemplateReport.steps_skipped_by_dry_run = 2
#    No funds moved. Fee numbers are returned for quoting.

9. Verify the on-chain counters

invocation_count and total_revenue are part of the template document itself. Read them back via tenzro_getAgentTemplate at any time:

# After N paid invocations, the template's on-chain counters grow monotonically
curl -s https://rpc.tenzro.network \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc":"2.0",
    "id":4,
    "method":"tenzro_getAgentTemplate",
    "params":[{"template_id":"ref-premium-alpha-advisor-v1"}]
  }' | jq '{
    template_id,
    creator_did,
    creator_wallet,
    pricing,
    invocation_count,
    total_revenue
  }'

Fee split recap

On every paid tenzro_runAgentTemplate call:

fee_paid           = pricing.price_for(tokens_estimate, max_iterations)
network_commission = fee_paid * 500 / 10_000       //   5% AGENT_MARKETPLACE_COMMISSION_BPS
creator_share      = fee_paid - network_commission //  95%

payer_wallet     -= fee_paid
treasury         += network_commission
creator_wallet   += creator_share
template.invocation_count += 1
template.total_revenue    += fee_paid

AGENT_MARKETPLACE_COMMISSION_BPS is fixed at 500 (5%) in tenzro_types. Free templates bypass the fee-collection path entirely — fee_paid = 0 and no treasury or creator credits are made.

What's next

You've shipped a paid agent on a live L1 and earned TNZO. From here: