Agent-to-Agent payments on TRON. Use when an agent needs to pay another agent, escrow funds, check credit scores, or verify on-chain identity.
---
name: em-a2a
description: 'Agent-to-Agent payments on TRON. Use when an agent needs to pay another agent, escrow funds, check credit scores, or verify on-chain identity.'
version: 0.1.0
tags:
- payment
- escrow
- defi
- tron
- identity
- credit
metadata:
openclaw:
emoji: '⚡'
requires:
env:
- A2A_NETWORK
- A2A_PRIVATE_KEY
primaryEnv: A2A_PRIVATE_KEY
---
# EM-A2A: Agent-to-Agent Payment Protocol
Agent-to-Agent payments, escrow, credit scoring, and identity on the TRON blockchain.
## When to Use This Skill
Use `em-a2a` when:
- **One agent needs to pay another agent** for services, data, or compute
- **Funds need to be held in escrow** until work is delivered and accepted
- **You need to check an agent's credit score** before trusting them
- **You need to verify an agent's on-chain identity** (DID + KYA)
- **You want to calculate protocol fees** before initiating a payment
**Not for:** Paying API endpoints (use paybot) or HTTP 402 interception (use x402).
## Tools
This skill provides 4 MCP tools via `@poisonpyf/a2a-mcp`:
| Tool | When to Call |
| ------------- | ----------------------------------------------------------------------- |
| `a2a_pay` | Transfer USDC/USDT from one agent to another |
| `a2a_escrow` | Lock funds before work starts, release on completion, refund on dispute |
| `a2a_credit` | Check credit score, level, trend, and leaderboard for an agent |
| `a2a_revenue` | Calculate protocol fee before initiating a transaction |
## Typical Workflow
### Hiring Another Agent
```
1. a2a_credit(agentId) → Check seller's reputation
2. a2a_revenue(amount, mode) → Understand the fee structure
3. a2a_escrow(action="lock") → Lock payment in escrow
4. [Seller delivers work]
5. a2a_escrow(action="release") → Release funds on acceptance
```
### Direct Payment (no escrow)
```
1. a2a_credit(agentId) → Check counterparty reputation
2. a2a_revenue(amount, mode) → Preview fees
3. a2a_pay(from, to, amount) → Execute direct transfer
```
## Setup
Add to your MCP client configuration:
```json
{
"mcpServers": {
"a2a": {
"command": "npx",
"args": ["-y", "@poisonpyf/a2a-mcp"],
"env": {
"A2A_NETWORK": "shasta",
"A2A_PRIVATE_KEY": "your-tron-private-key"
}
}
}
}
```
**Network:** Use `shasta` for testnet, `mainnet` for production.
## Tool Reference
### a2a_pay
Transfer tokens between agents. Handles AML screening, revenue calculation, and on-chain execution.
```json
{
"from": "did:bai:tron:TBu...",
"to": "did:bai:tron:TSa...",
"token": "USDC",
"amount": "1000000",
"memo": "Payment for smart contract audit"
}
```
### a2a_escrow
Lock/release/refund funds between agents.
```json
// Lock
{ "from": "...", "to": "...", "amount": "500000000", "action": "lock", "task": "Code review" }
// Release (use escrowId from lock result)
{ "from": "...", "to": "...", "amount": "500000000", "action": "release", "escrowId": "esc_abc123" }
// Refund
{ "from": "...", "to": "...", "amount": "500000000", "action": "refund", "escrowId": "esc_abc123" }
```
### a2a_credit
Check agent reputation and creditworthiness.
```json
{ "agentId": "did:bai:tron:TSa..." }
```
Returns score (300-950), level (excellent/good/fair/poor/none), trend history, and leaderboard.
### a2a_revenue
Preview protocol fees. Two modes:
- `fixed_tier`: Volume-based fixed rates (1.0% default, decreases with volume)
- `variable_float`: Risk-adjusted rates (lower risk + higher credit = lower fees)
```json
{ "amount": "100000000", "mode": "fixed_tier" }
```
## Architecture
```
Agent A (Client) Agent B (Server)
│ │
├─ a2a_credit(agentB) ──→ credit score
├─ a2a_revenue(amount) ─→ fee preview
├─ a2a_escrow(lock) ────→ funds locked
│ │
│ [Agent B delivers work] │
│ │
├─ a2a_escrow(release) ──→ funds released + credit updated
│ │
└────────── TRON blockchain ─────────┘
```
## Links
- GitHub: https://github.com/ypeng1620-beep/EM-A2A
- npm: https://www.npmjs.com/package/@poisonpyf/a2a-mcp
- TRON Shasta Faucet: https://www.trongrid.io/shasta
don't have the plugin yet? install it then click "run inline in claude" again.
added explicit intent, comprehensive inputs section with env var setup, detailed three-workflow procedure with edge cases, decision points for escrow vs direct pay and network failures, formal output contract with json schemas, and outcome signal section with testnet/mainnet verification steps.
use em-a2a when one agent needs to pay, escrow funds with, check credit scores for, or verify the on-chain identity of another agent on the tron blockchain. this skill handles direct transfers, escrow locking/release/refund, credit lookups, and fee previews. do not use for api endpoint payments (use paybot) or http 402 interception (use x402).
this skill enables trustless peer-to-peer payments between autonomous agents on tron. it supports three payment modes: direct transfer for trusted counterparties, escrow for conditional funding (work completion gates release), and credit/identity checks before transacting. use it anytime agent a needs to compensate agent b for services, compute, or data, or when you need to validate an agent's reputation before sending funds.
A2A_NETWORK: tron network identifier. set to shasta for testnet, mainnet for production. defaults to shasta if unset.A2A_PRIVATE_KEY: tron private key (64 hex characters) controlling the sender agent's wallet. do not commit to version control. store in secure env or secrets manager.@poisonpyf/a2a-mcp (npm package). installed via npx in mcp client config. requires node 16+.agentId: did:bai:tron: format agent identifier (credit/identity checks)from: sender did:bai:tron: wallet addressto: recipient did:bai:tron: wallet addressamount: transfer amount in smallest unit (6 decimals for usdc/usdt, e.g., 1000000 = 1 usdc)token: token symbol (usdc, usdt, trx). default usdc.action: escrow action (lock, release, refund)mode: fee calculation mode (fixed_tier, variable_float)memo: optional transaction note (max 255 chars)escrowId: returned from prior a2a_escrow lock callcall a2a_credit(agentId) with target agent's did. parse response for credit score (300-950 range), level (excellent/good/fair/poor/none), and trend. decide whether to proceed based on score threshold.
call a2a_revenue(amount, mode="fixed_tier") to preview protocol fee. this returns fee percentage and final deducted amount. confirm fee is acceptable.
call a2a_escrow(from, to, amount, action="lock", task="<description>"). this locks funds on-chain and returns escrowId. funds are held in contract, not transferred to recipient yet.
agent b (recipient) performs agreed work. both parties monitor completion off-chain or via external trigger.
upon work acceptance, call a2a_escrow(from, to, amount, action="release", escrowId). contract releases funds to recipient and auto-updates recipient's credit score upward.
on-chain transaction confirms. both agents' credit histories record the transaction. skill execution completes.
edge case: work rejection or dispute. if agent a rejects work, call a2a_escrow(from, to, amount, action="refund", escrowId) before the release deadline (typically 30 days). this returns funds to sender.
call a2a_credit(agentId) to validate counterparty reputation. confirm score is above your risk threshold.
call a2a_revenue(amount, mode) to understand fee structure. choose fixed_tier for volume discounts or variable_float for risk-adjusted pricing.
call a2a_pay(from, to, amount, token="USDC", memo). this executes immediate transfer, runs aml screening on-chain, deducts protocol fee, and transfers net amount to recipient. returns tx hash and confirmation.
poll tron mainnet or testnet explorer for tx confirmation (typically 3-5 seconds). skill completes once block confirms.
call a2a_credit(agentId) as in workflows 1 and 2. the response includes on-chain did validation, kya status (kyc-approved / pending / rejected), and leaderboard rank.
parse kya status. if rejected or pending, do not send funds until status clears.
proceed to payment workflow.
decision: should i escrow or pay directly?
decision: which fee mode?
fixed_tier if transaction amount is stable and you want predictable costs. good for recurring payments.variable_float if counterparty is new or high-risk. higher fee but adjusts down as credit improves over time.decision: what if the mcp server is offline or a2a_private_key is missing?
A2A_PRIVATE_KEY env var is unset or malformed, all calls fail with auth error. manually set the key before retrying. do not proceed without valid credentials.@poisonpyf/a2a-mcp server is unreachable, mcp client will timeout after 10 seconds. check network connectivity and restart mcp server. retry call.decision: what if tron network is congested?
decision: what if counterparty disputes an escrow release?
decision: what if the credit score endpoint returns no data (new agent)?
a2a_credit returns score=300 (none level). treat as untrusted. escrow only, no direct pay. as agent builds history, score increases.{
"txHash": "0xabc123...",
"from": "did:bai:tron:TBu...",
"to": "did:bai:tron:TSa...",
"amount": "1000000",
"fee": "10000",
"netAmount": "990000",
"token": "USDC",
"status": "confirmed",
"blockNumber": 45123456,
"timestamp": 1699564800
}
{
"escrowId": "esc_xyz789",
"from": "did:bai:tron:TBu...",
"to": "did:bai:tron:TSa...",
"amount": "500000000",
"status": "locked",
"task": "Code review",
"releaseDeadline": 1700169600,
"txHash": "0xdef456..."
}
{
"escrowId": "esc_xyz789",
"action": "release",
"status": "confirmed",
"txHash": "0xghi789...",
"timestamp": 1699650000
}
{
"agentId": "did:bai:tron:TSa...",
"score": 725,
"level": "good",
"trend": "up",
"kyaStatus": "kyc-approved",
"leaderboardRank": 142,
"transactionCount": 47,
"averageTransactionSize": "250000000",
"defaultRate": 0.002
}
{
"amount": "100000000",
"mode": "fixed_tier",
"feePercentage": 0.01,
"feeAmount": "1000000",
"netAmount": "99000000"
}
the skill worked if:
a2a_pay: tx hash is returned with status "confirmed". check tron scanner (https://tronscan.org for mainnet, https://shasta.tronscan.org for testnet) and confirm block number and recipient received amount. wait 3-5 seconds for confirmation.
a2a_escrow lock: escrowId is returned. funds disappear from your wallet and appear in escrow contract on-chain. verify on tron scanner by checking contract state.
a2a_escrow release: recipient's wallet balance increases by net amount. your credit score updates visibly on leaderboard within 1 minute. recipient's score increases.
a2a_credit: score and level are returned. compare to previous call to confirm data freshness. leaderboard rank should match on-chain record.
a2a_revenue: fee percentage is returned and matches documented fee schedule for the chosen mode. no funds move; this is a read-only preview.
failure indicators: tx hash is null, status is "pending" after 5 minutes, error message contains "insufficient balance", "invalid agent id", "network timeout", or "aml screening failed". check logs, validate inputs, and retry.
credits: original author undeclared. enriched per implexa standards with explicit decision logic, edge cases, network timeout handling, and output contracts. github source: https://github.com/ypeng1620-beep/EM-A2A