-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquickstart_agent.py
More file actions
49 lines (38 loc) · 1.31 KB
/
quickstart_agent.py
File metadata and controls
49 lines (38 loc) · 1.31 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
"""
AgentGatePay Python SDK - Agent Quickstart Example
Time to first payment: ~5 minutes
"""
import os
from agentgatepay_sdk import AgentGatePay
def main():
# Initialize client
client = AgentGatePay(
api_key=os.getenv("AGENTPAY_API_KEY"), # Optional
agent_id="my-ai-agent",
debug=True
)
print("=== AgentGatePay Agent Quickstart ===\n")
# Step 1: Issue a mandate
print("Step 1: Issuing mandate...")
mandate = client.mandates.issue(
subject="my-ai-agent@example.com",
budget=100, # $100 USD
scope="*",
ttl_minutes=1440 # 24 hours
)
print("Mandate issued!")
print(f" Token: {mandate['mandateToken'][:50]}...")
print(f" Expires: {mandate['expiresAt']}\n")
# Step 2: Submit payment with existing transaction
print("Step 2: Submitting payment...")
payment = client.payments.submit_tx_hash(
mandate=mandate["mandateToken"],
tx_hash="0x1234567890abcdef..." # Your blockchain transaction hash
)
print("Payment submitted!")
print(f" Status: {payment.get('status')}")
print(f" Amount: ${payment.get('amountUsd')}")
print(f" Budget remaining: ${payment.get('budgetRemaining')}\n")
print("✓ Complete! Your AI agent can now make payments.\n")
if __name__ == "__main__":
main()