Repository navigation
Expand file tree
/
Copy pathquickstart_example.py
More file actions
67 lines (58 loc) · 2.16 KB
/
Copy pathquickstart_example.py
File metadata and controls
67 lines (58 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
AgenticPay Bridge - 30-Second Quickstart Example
Demonstrates wallet creation, deposit, and autonomous A2A settlement.
"""
import urllib.request
import json
import time
BASE_URL = "http://localhost:8088"
def post(endpoint, data):
req = urllib.request.Request(
f"{BASE_URL}{endpoint}",
data=json.dumps(data).encode("utf-8"),
headers={"Content-Type": "application/json"}
)
with urllib.request.urlopen(req) as resp:
return json.loads(resp.read().decode("utf-8"))
def main():
print("[*] Testing AgenticPay Bridge Engine...")
# 1. Healthcheck
with urllib.request.urlopen(f"{BASE_URL}/health") as resp:
health = json.loads(resp.read().decode("utf-8"))
print(f"[+] Engine Status: {health['status']} | Chains: {health['supported_chains']}")
# 2. Create Sender Wallet
w_sender = post("/api/v1/wallets/create", {
"owner_id": "fintech_client_01",
"label": "AI Trading Desk",
"initial_balance": 1500.0,
"asset": "USDC"
})
print(f"[+] Sender Wallet Created: {w_sender['wallet_id']} (Balance: {w_sender['initial_balance']} USDC)")
# 3. Create Receiver Wallet
w_receiver = post("/api/v1/wallets/create", {
"owner_id": "service_agent_omega",
"label": "Cloud GPU Provider",
"initial_balance": 0.0,
"asset": "USDC"
})
print(f"[+] Receiver Wallet Created: {w_receiver['wallet_id']}")
# 4. Execute Autonomous A2A Settlement
tx = post("/api/v1/settlement/transfer", {
"sender_wallet_id": w_sender["wallet_id"],
"receiver_wallet_id": w_receiver["wallet_id"],
"amount": 42.50,
"asset": "USDC",
"chain": "base",
"nonce": int(time.time() * 1000)
})
print(f"[+] Autonomous A2A Transfer Settled!")
print(f" - Tx ID: {tx['tx_id']}")
print(f" - SHA-256 Proof: {tx['tx_hash']}")
print(f" - Latency: {tx['settlement_latency_ms']} ms")
if __name__ == "__main__":
try:
main()
except Exception as e:
print(f"[-] Could not connect to {BASE_URL}. Ensure the engine is running (`docker compose up -d`). Error: {e}")