Skip to content

Commit e18a993

Browse files
committed
fix: format markdown files with prettier
1 parent 24a8c1d commit e18a993

File tree

2 files changed

+55
-36
lines changed

2 files changed

+55
-36
lines changed

python/examples/README.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Ampersend SDK - Python Examples
22

3-
Comprehensive examples demonstrating x402 payment integration with A2A (Agent-to-Agent) and MCP (Model Context Protocol) protocols.
3+
Comprehensive examples demonstrating x402 payment integration with A2A (Agent-to-Agent) and MCP (Model Context Protocol)
4+
protocols.
45

56
## Prerequisites
67

@@ -62,12 +63,12 @@ You just made your first x402 payment on testnet! The agent automatically handle
6263

6364
### 1. A2A Direct Connection
6465

65-
**Path**: `src/examples/a2a/buyer/adk/`
66-
**Demonstrates**: Direct connection to remote A2A agent with x402 payments
66+
**Path**: `src/examples/a2a/buyer/adk/` **Demonstrates**: Direct connection to remote A2A agent with x402 payments
6767

6868
Connect directly to a remote agent and let the SDK handle payments automatically.
6969

7070
**Run**:
71+
7172
```bash
7273
# Testnet (staging)
7374
export EXAMPLES_A2A_BUYER__SMART_ACCOUNT_ADDRESS=0x...
@@ -78,18 +79,19 @@ uv --directory=python/examples run -- adk run src/examples/a2a/buyer/adk
7879
```
7980

8081
**Features**:
82+
8183
- Smart Account + EOA auto-detection
8284
- AmpersendTreasurer with spend limits
8385
- Defaults to staging subgraph service
8486

8587
### 2. A2A Local Orchestrator
8688

87-
**Path**: `src/examples/a2a/buyer/local_agent/`
88-
**Demonstrates**: Local agent orchestrating multiple remote agents
89+
**Path**: `src/examples/a2a/buyer/local_agent/` **Demonstrates**: Local agent orchestrating multiple remote agents
8990

9091
Build a local agent that can discover and delegate to multiple specialized remote agents.
9192

9293
**Run**:
94+
9395
```bash
9496
# Testnet (staging)
9597
export EXAMPLES_A2A_BUYER__SMART_ACCOUNT_ADDRESS=0x...
@@ -103,27 +105,29 @@ uv --directory=python/examples run -- adk run src/examples/a2a/buyer/local_agent
103105
```
104106

105107
**Features**:
108+
106109
- Uses `X402RemoteAgentToolset` for remote agent tools
107110
- Automatic agent discovery
108111
- Per-agent conversation context management
109112
- Multi-agent orchestration
110113

111114
**How it works**:
115+
112116
1. Orchestrator lists available remote agents
113117
2. Delegates user request to appropriate agent
114118
3. Remote agent processes with automatic payment
115119
4. Orchestrator returns result to user
116120

117121
### 3. MCP via Proxy
118122

119-
**Path**: `src/examples/mcp/buyer/adk/`
120-
**Demonstrates**: MCP protocol with transparent payment proxy
123+
**Path**: `src/examples/mcp/buyer/adk/` **Demonstrates**: MCP protocol with transparent payment proxy
121124

122125
Use MCP tools through a proxy that handles x402 payments transparently.
123126

124127
**Prerequisites**: Start the MCP proxy first (see [Running MCP Proxy](./docs/running-mcp-proxy.md))
125128

126129
**Run**:
130+
127131
```bash
128132
# 1. Start MCP proxy (separate terminal)
129133
export BUYER_SMART_ACCOUNT_ADDRESS=0x...
@@ -139,18 +143,19 @@ uv --directory=python/examples run -- adk run src/examples/mcp/buyer/adk
139143
```
140144

141145
**Features**:
146+
142147
- Transparent payment handling via proxy
143148
- No payment code in client agent
144149
- Works with any MCP server
145150

146151
### 4. A2A Seller
147152

148-
**Path**: `src/examples/a2a/seller/adk/`
149-
**Demonstrates**: Creating x402-enabled A2A services
153+
**Path**: `src/examples/a2a/seller/adk/` **Demonstrates**: Creating x402-enabled A2A services
150154

151155
Create your own A2A service that requires payment.
152156

153157
**Run**:
158+
154159
```bash
155160
export EXAMPLES_A2A_SELLER__PAY_TO_ADDRESS=0x...
156161
export GOOGLE_API_KEY=...
@@ -187,19 +192,22 @@ See [Environment Variables Reference](./docs/environment-variables.md) for compl
187192
### Quick Reference
188193

189194
**Smart Account Mode (Recommended)**:
195+
190196
```bash
191197
EXAMPLES_A2A_BUYER__SMART_ACCOUNT_ADDRESS=0x...
192198
EXAMPLES_A2A_BUYER__SMART_ACCOUNT_KEY_PRIVATE_KEY=0x...
193199
EXAMPLES_A2A_BUYER__AMPERSEND_API_URL=https://api.staging.ampersend.ai
194200
```
195201

196202
**Standalone Mode**:
203+
197204
```bash
198205
EXAMPLES_A2A_BUYER__PRIVATE_KEY=0x...
199206
EXAMPLES_A2A_BUYER__USE_NAIVE_AUTHORIZER=true
200207
```
201208

202209
**Service URLs** (optional, defaults to staging):
210+
203211
```bash
204212
EXAMPLES_A2A_BUYER__SELLER_AGENT_URL=https://subgraph-a2a.x402.staging.thegraph.com
205213
EXAMPLES_A2A_BUYER__AGENT_URL_1=https://subgraph-a2a.x402.staging.thegraph.com
@@ -270,33 +278,38 @@ EXAMPLE_BUYER__MCP__TARGET_SERVER_URL=https://subgraph-mcp.x402.staging.ampersen
270278
### "No module named 'ampersend_sdk'"
271279

272280
**Solution**: Install dependencies
281+
273282
```bash
274283
uv sync
275284
```
276285

277-
### "EXAMPLES_A2A_BUYER__SMART_ACCOUNT_ADDRESS" not found
286+
### "EXAMPLES_A2A_BUYER\_\_SMART_ACCOUNT_ADDRESS" not found
278287

279288
**Solutions**:
289+
280290
- **Smart Account mode**: Set all required smart account variables
281291
- **Standalone mode**: Use `EXAMPLES_A2A_BUYER__PRIVATE_KEY` instead
282292

283293
### "Insufficient funds" or "Payment rejected"
284294

285295
**Solutions**:
296+
286297
- **Testnet**: Get USDC from https://faucet.circle.com/ (Base Sepolia)
287298
- **Production**: Check balance in https://app.ampersend.ai
288299
- **Standalone**: Check your wallet USDC balance
289300

290301
### "Agent not found" (local_agent example)
291302

292303
**Solution**: Check `EXAMPLES_A2A_BUYER__AGENT_URL_1` is set and accessible:
304+
293305
```bash
294306
curl https://subgraph-a2a.x402.staging.thegraph.com/.well-known/agent-card.json
295307
```
296308

297309
### MCP Proxy Connection Refused
298310

299311
**Solutions**:
312+
300313
1. Check proxy is running: `curl http://localhost:3000/health`
301314
2. See [Running MCP Proxy Guide](./docs/running-mcp-proxy.md)
302315
3. Start proxy: `ampersend-proxy`

python/examples/docs/environment-variables.md

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,25 @@ Complete reference for all environment variables used in Ampersend SDK examples.
55
## Overview
66

77
Examples support two modes:
8+
89
1. **Smart Account + Ampersend** (recommended) - With spend limits and monitoring
910
2. **Standalone** - EOA + Naive mode for testing
1011

1112
## Smart Account Mode (Recommended)
1213

1314
### Required Variables
1415

15-
| Variable | Description | Example |
16-
|----------|-------------|---------|
17-
| `EXAMPLES_A2A_BUYER__SMART_ACCOUNT_ADDRESS` | Agent's smart account address | `0x1234...` |
16+
| Variable | Description | Example |
17+
| --------------------------------------------------- | ------------------------------------ | ----------- |
18+
| `EXAMPLES_A2A_BUYER__SMART_ACCOUNT_ADDRESS` | Agent's smart account address | `0x1234...` |
1819
| `EXAMPLES_A2A_BUYER__SMART_ACCOUNT_KEY_PRIVATE_KEY` | Session key (owner of smart account) | `0xabcd...` |
1920

2021
### Optional Variables
2122

22-
| Variable | Description | Default |
23-
|----------|-------------|---------|
24-
| `EXAMPLES_A2A_BUYER__AMPERSEND_API_URL` | Ampersend API endpoint | `https://api.staging.ampersend.ai` |
25-
| `EXAMPLES_A2A_BUYER__USE_NAIVE_AUTHORIZER` | Skip API checks | `false` |
23+
| Variable | Description | Default |
24+
| ------------------------------------------ | ---------------------- | ---------------------------------- |
25+
| `EXAMPLES_A2A_BUYER__AMPERSEND_API_URL` | Ampersend API endpoint | `https://api.staging.ampersend.ai` |
26+
| `EXAMPLES_A2A_BUYER__USE_NAIVE_AUTHORIZER` | Skip API checks | `false` |
2627

2728
### Setup
2829

@@ -37,10 +38,10 @@ Examples support two modes:
3738

3839
### Required Variables
3940

40-
| Variable | Description | Example |
41-
|----------|-------------|---------|
42-
| `EXAMPLES_A2A_BUYER__PRIVATE_KEY` | EOA wallet private key | `0xabcd...` |
43-
| `EXAMPLES_A2A_BUYER__USE_NAIVE_AUTHORIZER` | Enable naive mode | `true` |
41+
| Variable | Description | Example |
42+
| ------------------------------------------ | ---------------------- | ----------- |
43+
| `EXAMPLES_A2A_BUYER__PRIVATE_KEY` | EOA wallet private key | `0xabcd...` |
44+
| `EXAMPLES_A2A_BUYER__USE_NAIVE_AUTHORIZER` | Enable naive mode | `true` |
4445

4546
### Setup
4647

@@ -57,33 +58,33 @@ All examples default to staging services (testnet, rate-limited).
5758

5859
### A2A Service URLs
5960

60-
| Variable | Staging (Default) | Production |
61-
|----------|-------------------|------------|
61+
| Variable | Staging (Default) | Production |
62+
| -------------------------------------- | ------------------------------------------------ | ---------------------------------------- |
6263
| `EXAMPLES_A2A_BUYER__SELLER_AGENT_URL` | `https://subgraph-a2a.x402.staging.thegraph.com` | `https://subgraph-a2a.x402.thegraph.com` |
6364

6465
### Local Orchestrator URLs
6566

66-
| Variable | Staging (Default) | Production |
67-
|----------|-------------------|------------|
67+
| Variable | Staging (Default) | Production |
68+
| --------------------------------- | ------------------------------------------------ | ---------------------------------------- |
6869
| `EXAMPLES_A2A_BUYER__AGENT_URL_1` | `https://subgraph-a2a.x402.staging.thegraph.com` | `https://subgraph-a2a.x402.thegraph.com` |
69-
| `EXAMPLES_A2A_BUYER__AGENT_URL_2` | _(optional)_ | _(optional)_ |
70+
| `EXAMPLES_A2A_BUYER__AGENT_URL_2` | _(optional)_ | _(optional)_ |
7071

7172
### MCP Service URLs
7273

73-
| Variable | Staging (Default) | Production |
74-
|----------|-------------------|------------|
75-
| `EXAMPLE_BUYER__MCP__PROXY_URL` | `http://localhost:3000/mcp` | `http://localhost:3000/mcp` |
74+
| Variable | Staging (Default) | Production |
75+
| --------------------------------------- | ------------------------------------------------ | ---------------------------------------- |
76+
| `EXAMPLE_BUYER__MCP__PROXY_URL` | `http://localhost:3000/mcp` | `http://localhost:3000/mcp` |
7677
| `EXAMPLE_BUYER__MCP__TARGET_SERVER_URL` | `https://subgraph-mcp.x402.staging.ampersend.ai` | `https://subgraph-mcp.x402.thegraph.com` |
7778

7879
### MCP Proxy Configuration
7980

80-
| Variable | Description | Default |
81-
|----------|-------------|---------|
82-
| `BUYER_SMART_ACCOUNT_ADDRESS` | Smart account for proxy | _(required)_ |
83-
| `BUYER_SMART_ACCOUNT_KEY_PRIVATE_KEY` | Session key for proxy | _(required)_ |
84-
| `BUYER_SMART_ACCOUNT_VALIDATOR_ADDRESS` | Validator contract | `0x000000000013FDB5234E4E3162A810F54D9F7E98` |
85-
| `AMPERSEND_API_URL` | Ampersend API for proxy | _(required)_ |
86-
| `BUYER_PRIVATE_KEY` | EOA private key (standalone) | _(alternative)_ |
81+
| Variable | Description | Default |
82+
| --------------------------------------- | ---------------------------- | -------------------------------------------- |
83+
| `BUYER_SMART_ACCOUNT_ADDRESS` | Smart account for proxy | _(required)_ |
84+
| `BUYER_SMART_ACCOUNT_KEY_PRIVATE_KEY` | Session key for proxy | _(required)_ |
85+
| `BUYER_SMART_ACCOUNT_VALIDATOR_ADDRESS` | Validator contract | `0x000000000013FDB5234E4E3162A810F54D9F7E98` |
86+
| `AMPERSEND_API_URL` | Ampersend API for proxy | _(required)_ |
87+
| `BUYER_PRIVATE_KEY` | EOA private key (standalone) | _(alternative)_ |
8788

8889
## Complete Configuration Examples
8990

@@ -164,6 +165,7 @@ export BUYER_PRIVATE_KEY=0x...
164165
## Smart Account Configuration
165166

166167
The validator address for Smart Accounts:
168+
167169
```
168170
0x000000000013FDB5234E4E3162A810F54D9F7E98
169171
```
@@ -175,18 +177,21 @@ This is the same across staging and production.
175177
### How do I know which mode I'm in?
176178

177179
Check your environment variables:
180+
178181
- If `EXAMPLES_A2A_BUYER__SMART_ACCOUNT_ADDRESS` is set → **Smart Account mode**
179182
- If only `EXAMPLES_A2A_BUYER__PRIVATE_KEY` is set → **Standalone mode**
180183

181184
### Can I mix variables from different modes?
182185

183186
No. Choose one mode:
187+
184188
- **Smart Account**: Set `SMART_ACCOUNT_ADDRESS` + `SMART_ACCOUNT_KEY_PRIVATE_KEY` + `AMPERSEND_API_URL`
185189
- **Standalone**: Set `PRIVATE_KEY` + `USE_NAIVE_AUTHORIZER=true`
186190

187191
### What happens if I don't set service URLs?
188192

189193
Examples default to staging services:
194+
190195
- A2A: `https://subgraph-a2a.x402.staging.thegraph.com`
191196
- MCP: `https://subgraph-mcp.x402.staging.ampersend.ai`
192197

@@ -195,6 +200,7 @@ This is perfect for getting started!
195200
### How do I switch to production?
196201

197202
Update three variables:
203+
198204
1. `AMPERSEND_API_URL=https://api.ampersend.ai`
199205
2. Service URL to production endpoint
200206
3. Ensure using production account from https://app.ampersend.ai

0 commit comments

Comments
 (0)